vml柱状图:ASP结合VML生成柱状图来源: 发布时间:星期四, 2009年2月12日 浏览:218次 评论:0
<% ’ ’ 介绍说明此代码根据网络上 ![]() ’ 数据结构:tblCart(str,long) ’ Dim strConn,strDBPath strDBPath = \"db1.mdb\" strConn = \"Provider=Microsoft.Jet.Oledb.4.0;Data Source=\" & Server.MapPath(strDBPath) Set objConn = Server.CreateObject(\"ADODB.Connection\") objConn.Open strConn Set objRs = Server.CreateObject(\"ADODB.Record ![]() strSQL = \"SELECT * FROM tblChart\" objRs.Open strSQL,objConn, 3, 2 total_no = objRs.RecordCount Redim total(total_no,2) Dim i i = 0 While Not objRs.EOF i = i + 1 total(i,1) = Trim(objRs.Fields(2).Value) total(i,2) = Trim(objRs.Fields(1).Value) objRs.MoveNext Wend If objRs.State = adStateOpen Then objRs.Close ![]() If objConn.State = adStateOpen Then objConn.Close ![]() %> <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> <![end ![]() <head> <meta http-equiv=\"Content-Type\" content=\"text/html; char ![]() <title></title> <style> TD { FONT-SIZE: 9pt} </style></head> <body topmargin=5 leftmargin=0 scroll=AUTO> <%Call createHistogram(total,200,20,20,30,400,200,\"A\")%> <%Call createHistogram(total,200,320,20,20,400,250,\"B\")%> </body> </html> <% Function createHistogram(total,table_x,table_y,thickness,table_width,all_width,all_height,table_type) ’参数含义(传递 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ’纯ASP代码生成图表 ![]() strColor = \"d1ffd1,ffbbbb,ffe3bb,cff4f3,d9d9e5,ffc7ab,ecffb7,00ff00,ff0000,ff9900,33cccc,666699,993300,99cc00\" arrColor = Split(strColor,\",\") Redim tb_color(total_no,2) Dim j ’Response.Write \"Ubound(tb_color)=\" & Ubound(tb_color) For j = 1 To Ubound(tb_color) Randomize ’ ![]() ![]() rndValue = Int((13 * Rnd) + 1) If rndValue = 13 Then rndValue = 12 tb_color(j,1)=\"#\" & arrColor(rndValue)’\"#d1ffd1\" tb_color(j,2)=\"#\" & arrColor(rndValue+1)’\"#00ff00\" Next line_color=\"#69f\" left_width=70 length=thickness/2 total_no=Ubound(total,1) temp1=0 For i=1 To total_no If temp1 < CLng(total(i,1)) Then temp1=CLng(total(i,1)) Next temp1=CInt(temp1) If temp1>9 Then temp2=mid(cstr(temp1),2,1) If temp2 > 4 Then temp3=( ![]() Else temp3=( ![]() 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=’100%’ type=’gradient’/></v:rect><![end ![]() 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’/><![end ![]() 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’/><![end ![]() Select Case table_type Case \"A\" 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&\"’/> <![end ![]() For i=0 To 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&\"’/><![end ![]() 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&\"’/><![end ![]() 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’/><![end ![]() Response.write \"<!--[If gte vml 1]>\" & VbCrLf 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’>[Page] \" & VbCrLf Response.write \"<v:textbox in ![]() ![]() 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=’_x0000_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)&\"’>\" & VbCrLf Response.write \"<v:fill color2=’\"&tb_color(i,1)&\"’ rotate=’t’ type=’gradient’/>\" & VbCrLf Response.write \"<o:extrusion v:ext=’view’ backdepth=’\"&thickness&\"pt’ color=’\"&tb_color(i,2)&\"’ _disibledevent=> Response.write \"</v:rect>\" & VbCrLf 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’>\" [Page] Response.write \"<v:textbox in ![]() 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 in ![]() 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&\"’/><![end ![]() 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&\"’/><![end ![]() 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&\"’/><![end ![]() 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’/><![end ![]() 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 in ![]() ![]() 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=’_x0000_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)&\"’>\" [Page] Response.write \"<v:fill color2=’\"&tb_color(i,1)&\"’ rotate=’t’ angle=’-90’ focus=’100%’ type=’gradient’/>\" Response.write \"<o:extrusion v:ext=’view’ backdepth=’\"&thickness&\"pt’ color=’\"&tb_color(i,2)&\"’ _disibledevent=> 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 in ![]() 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 in ![]() Next Case Else End Select End Function %> 0
相关文章读者评论发表评论 |