前往顾页
以后地位: 主页 > 收集编程 > Asp实例教程 >

操纵asp代码天生统计图--柱状图-折线图等

时候:2010-05-13 11:11来源:知行网www.zhixing123.cn 编辑:麦田守望者

 

  1. <%  
  2. function table1(total,table_x,table_y,thickness,table_width,all_width,all_height,table_type)  
  3. ’参数含义(通报的数组,横坐标,纵坐标,柱子的厚度,柱子的宽度,图表的宽度,图表的高度,图表的范例)  
  4. ’纯ASP代码天生图表函数1——柱状图  
  5. ’作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@sina.com Email:passwordgm@sina.com  
  6. ’自己非常愿意和ASP,VML,FLASH的喜好者在HTTP://topclouds.126.com进行交换和切磋  
  7. ’版本2.0 最后点窜日期 2003-7-22  
  8. ’非常感激您利用这个函数,请您利用和转载时保存版权信息,这是对作者事情的最好的尊敬。  
  9. dim tb_color(7,2)  
  10. tb_color(1,1)="#d1ffd1" 
  11. tb_color(2,1)="#ffbbbb" 
  12. tb_color(3,1)="#ffe3bb" 
  13. tb_color(4,1)="#cff4f3" 
  14. tb_color(5,1)="#d9d9e5" 
  15. tb_color(6,1)="#ffc7ab" 
  16. tb_color(7,1)="#ecffb7" 
  17.  
  18. tb_color(1,2)="#00ff00" 
  19. tb_color(2,2)="#ff0000" 
  20. tb_color(3,2)="#ff9900" 
  21. tb_color(4,2)="#33cccc" 
  22. tb_color(5,2)="#666699" 
  23. tb_color(6,2)="#993300" 
  24. tb_color(7,2)="#99cc00" 
  25.  
  26. line_color="#69f" 
  27. left_width=70  
  28. length=thickness/2  
  29. total_no=ubound(total,1)  
  30.  
  31. temp1=0  
  32. for i=1 to total_no  
  33. if temp1<total(i,1) then temp1=total(i,1)  
  34. next  
  35. temp1=int(temp1)  
  36. if temp1>9 then  
  37. temp2=mid(cstr(temp1),2,1)  
  38. if temp2>4 then   
  39. temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+1)*10^(len(cstr(temp1))-1)  
  40. else 
  41. temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+0.5)*10^(len(cstr(temp1))-1)  
  42. end if 
  43. else 
  44. if temp1>4 then temp3=10 else temp3=5  
  45. end if 
  46. temp4=temp3  
  47. 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><![endif]-->" 
  48. 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]-->" 
  49. 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]-->" 
  50.  
  51. select case table_type  
  52. case "A" 
  53. table_space=(all_width-table_width*total_no)/total_no  
  54. 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]-->" 
  55. for i=0 to all_height-1 step all_height/5  
  56. 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]-->" 
  57. 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]-->" 
  58. 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]-->" 
  59. response.write "<!--[if gte vml 1]>" 
  60. 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’>" 
  61. response.write "<v:textbox inset=’0px,0px,0px,0px’><table cellspacing=’3’ cellpadding=’0’ width=’100%’ height=’100%’><tr><td align=’right’>"&temp4&"</td></tr></table></v:textbox></v:shape><![endif]-->" 
  62. temp4=temp4-temp3/5  
  63. next  
  64. for i=1 to total_no  
  65. temp_space=table_x+left_width+table_space/2+table_space*(i-1)+table_width*(i-1)  
  66. response.write "<v:rect id=’_x0000_s1025’ alt=’’ style=’position:absolute;left:" 
  67. response.write temp_space  
  68. response.write "px;top:" 
  69. response.write table_y+all_height*(1-(total(i,1)/temp3))  
  70. response.write "px;width:"&table_width&"px;height:"&all_height*(total(i,1)/temp3)&"px;z-index:1’ fillcolor=’"&tb_color(i,2)&"’>" 
  71. response.write "<v:fill color2=’"&tb_color(i,1)&"’ rotate=’t’ type=’gradient’/>" 
  72. response.write "<o:extrusion v:ext=’view’ backdepth=’"&thickness&"pt’ color=’"&tb_color(i,2)&"’ on=’t’/>" 
  73. response.write "</v:rect>" 
  74. 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’>" 
  75. response.write "<v:textbox inset=’0px,0px,0px,0px’><table cellspacing=’3’ cellpadding=’0’ width=’100%’ height=’100%’><tr><td align=’center’>"&total(i,1)&"</td></tr></table></v:textbox></v:shape>" 
  76.  
  77. 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’>" 
  78. response.write "<v:textbox inset=’0px,0px,0px,0px’><table cellspacing=’3’ cellpadding=’0’ width=’100%’ height=’100%’><tr><td align=’center’>"&total(i,2)&"</td></tr></table></v:textbox></v:shape>" 
  79. next  
  80. Case "B" 
  81. table_space=(all_height-table_width*total_no)/total_no  
  82. 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]-->" 
  83. for i=0 to all_width-1 step all_width/5  
  84. 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]-->" 
  85. 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]-->" 
  86. 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]-->" 
  87. response.write "<!--[if gte vml 1]>" 
  88. 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’>" 
  89. response.write "<v:textbox inset=’0px,0px,0px,0px’><table cellspacing=’3’ cellpadding=’0’ width=’100%’ height=’100%’><tr><td align=’right’>"&temp4&"</td></tr></table></v:textbox></v:shape><![endif]-->" 
  90. temp4=temp4-temp3/5  
  91. next  
  92.  
  93. for i=1 to total_no  
  94. temp_space=table_space/2+table_space*(i-1)+table_width*(i-1)  
  95. response.write "<v:rect id=’_x0000_s1025’ alt=’’ style=’position:absolute;left:" 
  96. response.write table_x+left_width  
  97. response.write "px;top:" 
  98. response.write table_y+temp_space  
  99. response.write "px;width:"&all_width*(total(i,1)/temp3)&"px;height:"&table_width&"px;z-index:1’ fillcolor=’"&tb_color(i,2)&"’>" 
  100. response.write "<v:fill color2=’"&tb_color(i,1)&"’ rotate=’t’ angle=’-90’ focus=’100%’ type=’gradient’/>" 
  101. response.write "<o:extrusion v:ext=’view’ backdepth=’"&thickness&"pt’ color=’"&tb_color(i,2)&"’ on=’t’/>" 
  102. response.write "</v:rect>" 
  103. 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’>" 
  104. response.write "<v:textbox inset=’0px,0px,0px,0px’><table cellspacing=’3’ cellpadding=’0’ width=’100%’ height=’100%’><tr><td align=’center’>"&total(i,1)&"</td></tr></table></v:textbox></v:shape>" 
  105.  
  106. 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’>" 
  107. response.write "<v:textbox inset=’0px,0px,0px,0px’><table cellspacing=’3’ cellpadding=’0’ width=’100%’ height=’100%’><tr><td align=’right’>"&total(i,2)&"</td></tr></table></v:textbox></v:shape>" 
  108. next  
  109. case else 
  110. end select  
  111.  
  112. end function 
  113. %>  
  114. <%  
  115. dim total(7,2)  
  116. total(1,1)=200  
  117. total(2,1)=800  
  118. total(3,1)=1000  
  119. total(4,1)=600  
  120. total(5,1)=1222  
  121. total(6,1)=3213  
  122. total(7,1)=8  
  123.  
  124. total(1,2)="中国经营报" 
  125. total(2,2)="雇用网" 
  126. total(3,2)="51Job" 
  127. total(4,2)="新民晚报" 
  128. total(5,2)="消息晚报" 
  129. total(6,2)="南边周末" 
  130. total(7,2)="羊城晚报" 
  131.  
  132. total_no=7  
  133. %>  
  134. <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">  
  135. <!--[if !mso]>  
  136. <style>  
  137. v\:* { behavior: url(#default#VML) }  
  138. o\:* { behavior: url(#default#VML) }  
  139. .shape { behavior: url(#default#VML) }  
  140. </style>  
  141. <![endif]-->  
  142. <head>  
  143. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
  144. <title></title>  
  145. <style>  
  146. TD { FONT-SIZE: 9pt}  
  147. </style></head>  
  148. <body topmargin=5 leftmargin=0 scroll=AUTO>  
  149. <%call table1(total,200,20,20,30,400,200,"A")%>  
  150. <%call table1(total,200,320,20,20,400,250,"B")%>  
  151. </body>  
  152. </html>  

 

------分开线----------------------------
标签(Tag):asp代码 asp实例
------分开线----------------------------
保举内容
猜你感兴趣