Use ASP and VML to generate a perfect chart-bar chart

Source: Internet
Author: User

From: http://goaler.xicp.net/ShowLog.asp? Id = 431
Demo: http://goaler.xicp.net/Demo/asp_vml_pic3.asp
<%
Dim total (7,2)
Total (1, 1) = 200
Total (2, 1) = 800
Total (3, 1) = 1000
Total (4, 1) = 600
Total (5, 1) = 1222
Total (6, 1) = 3213
Total (7,1) = 8

Total (1, 2) = "China Business News"
Total (2, 2) = "recruitment network"
Total (3, 2) = "51job"
Total (4, 2) = "Xinmin Evening News"
Total (5, 2) = "Evening News"
Total (6, 2) = "Southern Weekend"
Total (7,2) = "Yangcheng Evening News"

Total_no = 7
%>
<HTML xmlns: V = "urn: Schemas-Microsoft-com: VML" xmlns: O = "urn: Schemas-Microsoft-com: Office: office">
<! -- [If! MSO]>
<Style>
V \: * {behavior: URL (# default # VML )}
O \: * {behavior: URL (# default # VML )}
. Shape {behavior: URL (# default # VML )}
</Style>
<! [Endif] -->
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> </title>
<Style>
TD {font-size: 9pt}
</Style> <Body topmargin = 5 leftmargin = 0 scroll = auto>
<% Call Table1 (total, 400,200, 20, 30, "A") %>
<% Call Table1 (total, 200,320, 20, 400,250, "B") %>
</Body>
</Html>

<%
Function Table1 (total, table_x, table_y, thickness, table_width, all_width, all_height, table_type)
'Parameter meaning (transmitted array, abscissa, ordinate, column thickness, column width, chart width, chart height, chart type)
'Chart function 1 generated using ASP code -- bar chart
'Author: passwordgm QQ: 25968152 MSN: passwordgm@sina.com Email: passwordgm@sina.com
'I am very willing to discuss with ASP, VML, and Flash fans at http: // topclouds.126.com.
'Version 2.0 last modified on
'Thank you very much for using this function. Please retain the copyright information when you use and repost it. This is the best respect for the work of the author.
Dim tb_color (7,2)
Tb_color (1, 1) = "# d1ffd1"
Tb_color (2, 1) = "# ffbbbb"
Tb_color (3,1) = "# ffe3bb"
Tb_color (4,1) = "# cff4f3"
Tb_color (5, 1) = "# d9d9e5"
Tb_color (6, 1) = "# ffc7ab"
Tb_color (7,1) = "# ecffb7"

Tb_color (1, 2) = "#00ff00"
Tb_color (2, 2) = "# ff0000"
Tb_color (3, 2) = "# ff9900"
Tb_color (4, 2) = "#33 CCCC"
Tb_color (666699) ="
Tb_color (6, 2) = "#993300"
Tb_color (7,2) = "#99cc00"

Line_color = "# 69f"
Left_width = 70
Length = thickness/2
Total_no = ubound (total, 1)

Temp1 = 0
For I = 1 to total_no
If temp1 <total (I, 1) Then temp1 = total (I, 1)
Next
Temp1 = int (temp1)
If temp1> 9 then
Temp2 = mid (CSTR (temp1), 2, 1)
If temp2> 4 then
Temp3 = (INT (temp1/(10 ^ (LEN (CSTR (temp1)-1) + 1) * 10 ^ (LEN (CSTR (temp1)-1)
Else
Temp3 = (INT (temp1/(10 ^ (LEN (CSTR (temp1)-1) + 0.5) * 10 ^ (LEN (CSTR (temp1)-1)
End if
Else
If temp1> 4 then temp3 = 10 else temp3 = 5
End if
Temp4 = temp3
Response. Write "<! -- [If gte vml 1]> <v: rect id = '_ x0000_s1027 'alt = ''style = 'position: absolute; left:" & table_x + left_width & "PX; top: "& table_y &" PX; width: "& all_width &" PX; Height: "& all_height &" PX; Z-index: -1 'fillcolor = '# 9cf 'stroked = 'F'> <V: fill rotate = 't'angle = '-45' focus = '000000' type = 'gradient'/> </V: rect> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width &" PX, "& table_y + all_height &" PX 'To =' "& table_x + all_width + left_width &" PX, "& table_y + all_height &" PX '/> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width &" PX, "& table_y &" PX 'To =' "& table_x + left_width &" PX, "& table_y + all_height &" PX '/> <! [Endif] -->"

Select case table_type
Case ""
Table_space = (all_width-table_width * total_no)/total_no
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width + Length &" PX, "& table_y &" PX 'To =' "& table_x + left_width + Length &" PX, "& table_y + all_height-length &" PX 'strokecolor = '"& line_color &"'/> <! [Endif] -->"
For I = 0 to the all_height-1 step all_height/5
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width &" PX, "& table_y + all_height-length-i &" PX 'To =' "& table_x + left_width + Length &" PX, "& table_y + all_height-i &" PX 'strokecolor = '"& line_color &"'/> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width + Length &" PX, "& table_y + all_height-length-i &" PX 'To =' "& table_x + all_width + left_width &" PX, "& table_y + all_height-length-i &" PX 'strokecolor = '"& line_color &"'/> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from =' "& table_x + (left_width-15) &" PX, "& table_y + I &" PX 'To =' "& table_x + left_width &" PX, "& table_y + I &" PX '/> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]>"
Response. write "<v: Shape id = '_ x0000_s1025' type = '# _ x0000_t202' alt ='' style = 'position: absolute; left: "& table_x &" PX; top: "& table_y + I &" PX; width: "& left_width &" PX; Height: 18px; Z-index: 1'>"
Response. write "<v: textbox inset = '0px, 0px, 0px, 0px '> <Table cellspacing = '3' cellpadding = '0' width = '000000' Height = '000000'> <tr> <TD align = 'right'> "& temp4 & "</TD> </tr> </table> </V: textbox> </V: Shape> <! [Endif] -->"
Temp4 = temp4-temp3/5
Next

For I = 1 to total_no
Temp_space = table_x + left_width + table_space/2 + table_space * (I-1) + table_width * (I-1)
Response. Write "<v: rect id = '_ x1__s1025' alt ='' style = 'position: absolute; left :"
Response. Write temp_space
Response. Write "PX; top :"
Response. Write table_y + all_height * (1-(total (I, 1)/temp3 ))
Response. write "PX; width:" & table_width & "PX; Height:" & all_height * (total (I, 1)/temp3) & "PX; Z-index: 1 'fillcolor = '"& tb_color (I, 2) &"'>"
Response. Write "<v: Fill color2 = '" & tb_color (I, 1) & "'rotate = 't'type = 'gradient'/>"
Response. write "<O: extrusion V: ext = 'view' backdepth = '" & thickness & "PT 'color ='" & tb_color (I, 2) & "'on =' t'/>"
Response. Write "</V: rect>"
Response. write "<v: Shape id = '_ x0000_s1025' type = '# _ x0000_t202' alt ='' style = 'position: absolute; left: "& temp_space &" PX; top: "& table_y + all_height * (1-(total (I, 1)/temp3)-table_width &" PX; width: "& table_space + 15 &" PX; height: 18px; Z-index: 1'>"
Response. write "<v: textbox inset = '0px, 0px, 0px, 0px '> <Table cellspacing = '3' cellpadding = '0' width = '000000' Height = '000000'> <tr> <TD align = 'center'> "& total (I, 1) & "</TD> </tr> </table> </V: textbox> </V: Shape>"

Response. write "<v: Shape id = '_ x0000_s1025' type = '# _ x0000_t202' alt ='' style = 'position: absolute; left: "& temp_space-table_space/2 &" PX; top: "& table_y + all_height + 1 &" PX; width: "& table_space + table_width &" PX; Height: 18px; z-index: 1'>"
Response. write "<v: textbox inset = '0px, 0px, 0px, 0px '> <Table cellspacing = '3' cellpadding = '0' width = '000000' Height = '000000'> <tr> <TD align = 'center'> "& total (I, 2) & "</TD> </tr> </table> </V: textbox> </V: Shape>"
Next
Case "B"
Table_space = (all_height-table_width * total_no)/total_no
Temp4 = temp3/5
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width + Length &" PX, "& table_y + all_height-length &" PX 'To =' "& table_x + left_width + all_width &" PX, "& table_y + all_height-length &" PX 'strokecolor = '"& line_color &"'/> <! [Endif] -->"
For I = 0 to all_width-1 step all_width/5
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width + I &" PX, "& table_y + all_height-length &" PX 'To =' "& table_x + left_width + Length + I &" PX, "& table_y + all_height &" PX 'strokecolor = '"& line_color &"'/> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width + Length + I &" PX, "& table_y + all_height-length &" PX 'To =' "& table_x + left_width + Length + I &" PX, "& table_y &" PX 'strokecolor = '"& line_color &"'/> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]> <v: Line id = '_ x0000_s1027' alt = ''style = 'position: absolute; left: 0; text-align: left; top: 0; flip: Y; Z-index:-1 'from = '"& table_x + left_width + I + all_width/5 &" PX, "& table_y + all_height &" PX 'To =' "& table_x + left_width + I + all_width/5 &" PX, "& table_y + all_height + 15 &" PX '/> <! [Endif] -->"
Response. Write "<! -- [If gte vml 1]>"
Response. write "<v: Shape id = '_ x0000_s1025' type = '# _ x0000_t202' alt ='' style = 'position: absolute; left: "& table_x + left_width + I + all_width/5-left_width &" PX; top: "& table_y + all_height &" PX; width: "& left_width &" PX; Height: 18px; z-index: 1'>"
Response. write "<v: textbox inset = '0px, 0px, 0px, 0px '> <Table cellspacing = '3' cellpadding = '0' width = '000000' Height = '000000'> <tr> <TD align = 'right'> "& temp4 & "</TD> </tr> </table> </V: textbox> </V: Shape> <! [Endif] -->"
Temp4 = temp4 + temp3/5
Next

For I = 1 to total_no
Temp_space = table_space/2 + table_space * (I-1) + table_width * (I-1)
Response. Write "<v: rect id = '_ x1__s1025' alt ='' style = 'position: absolute; left :"
Response. Write table_x + left_width
Response. Write "PX; top :"
Response. Write table_y + temp_space
Response. write "PX; width:" & all_width * (total (I, 1)/temp3) & "PX; Height:" & table_width & "PX; Z-index: 1 'fillcolor = '"& tb_color (I, 2) &"'>"
Response. write "<v: Fill color2 = '" & tb_color (I, 1) & "'rotate = 't'angle = '-90' focus = '000000' type = 'gradient'/>"
Response. write "<O: extrusion V: ext = 'view' backdepth = '" & thickness & "PT 'color ='" & tb_color (I, 2) & "'on =' t'/>"
Response. Write "</V: rect>"
Response. write "<v: Shape id = '_ x0000_s1025' type = '# _ x0000_t202' alt ='' style = 'position: absolute; left: "& table_x + left_width + all_width * (total (I, 1)/temp3) + thickness/2 &" PX; top: "& table_y + temp_space &" PX; width: "& table_space + 15 &" PX; Height: 18px; Z-index: 1'>"
Response. write "<v: textbox inset = '0px, 0px, 0px, 0px '> <Table cellspacing = '3' cellpadding = '0' width = '000000' Height = '000000'> <tr> <TD align = 'center'> "& total (I, 1) & "</TD> </tr> </table> </V: textbox> </V: Shape>"

Response. write "<v: Shape id = '_ x0000_s1025' type = '# _ x0000_t202' alt ='' style = 'position: absolute; left: "& table_x &" PX; top: "& table_y + temp_space &" PX; width: "& left_width &" PX; Height: 18px; Z-index: 1'>"
Response. write "<v: textbox inset = '0px, 0px, 0px, 0px '> <Table cellspacing = '3' cellpadding = '0' width = '000000' Height = '000000'> <tr> <TD align = 'right'> "& total (I, 2) & "</TD> </tr> </table> </V: textbox> </V: Shape>"
Next
Case else
End select

End Function
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.