一个统计直方图的函数

来源:互联网 发布:数据库表字段设计原则 编辑:程序博客网 时间:2024/05/17 11:56

<%
'参数含义(数组,横坐标,纵坐标,图表的宽度,图表的高度,图表标题,X轴单位,Y轴单位)
function table1(stat_array,table_left,table_top,all_width,all_height,table_title,X_unit,Y_unit)
num =ubound(stat_array,1)
dim bg_color(num)
bg_color(0)="#ff1919"
bg_color(1)="#ffff19"
bg_color(2)="#1919ff"
bg_color(3)="#19ff19"
bg_color(4)="#1c00"
bg_color(5)="#5c11"
bg_color(6)="#9c22"
bg_color(7)="#fc33"
bg_color(8)="#4244"

if X_unit<>"" then
X_unit=X_unit
end if
if Y_unit<>"" then
Y_unit=Y_unit
end if

item_width = cint(20000/num+0.5)
begin_x= cint((item_width-1200)/2)+2200

value_Max=0
for i=1 to num
if value_Max<stat_array(i,1) then value_Max=stat_array(i,1)
next
value_Max = cint(value_Max)
value_Max_str =cstr(value_Max)
if value_Max>9 then
temp=mid(value_Max_str,2,1)
response.write temp&"<br>"
if temp>9 then
temp2=(int(value_Max/(18^(len(value_Max_str)-1)))+1)*18^(len(value_Max_str)-1)
else
temp2=(int(value_Max/(18^(len(value_Max_str)-1)))+0.5)*18^(len(value_Max_str)-1)
end if
else
if value_Max>9 then temp2=num*2  else temp2=num
end if
item_hight = temp2/num

response.Write "<v:shapetype id='Box' coordsize='21600,21600' o:spt='16' adj='5400'></v:shapetype>"

response.Write "<v:rect id='background' style='position:absolute;left:"&table_left&"px;top:"&table_top&"px;WIDTH:"&all_width&"px;HEIGHT:"&all_height&"px;' fillcolor='#EFEFEF' strokecolor='gray'>"
response.Write " <v:shadow on='t' type='single' color='silver' offset='4pt,4pt'/>"
response.Write "</v:rect>"

response.Write "<v:group ID='table' style='position:absolute;left:"&table_left&"px;top:"&table_top&"px;WIDTH:"&all_width&"px;HEIGHT:"&all_height&"px;' coordsize = '23500,12700'>"

response.Write " <v:Rect style='position:relative;left:1500;top:200;width:20000;height:800'filled='false' stroked='false'>"
response.Write " <v:TextBox inset='0pt,0pt,0pt,0pt'>"
response.Write " <table width='100%' border='0' align='center' cellspacing='0'>"
response.Write " <tr>"
response.Write " <td align='center' valign='middle'><div style='font-size:12pt; font-family:黑体;'><B>"&table_title&"</B></div></td>"
response.Write " </tr>"
response.Write " </table>"
response.Write " </v:TextBox>"
response.Write " </v:Rect> "

response.Write " <v:rect id='back' style='position:relative;left:1700;top:1200;width:20500; height:9500;' fillcolor='#9cf' strokecolor='#DFDFDF'>"
response.Write " <v:fill rotate='t' angle='-45' focus='100%' type='gradient'/>"
response.Write " </v:rect>"
response.Write " <v:line ID='X' from='1700,10700' to='22700,10700' style='z-index:2' strokecolor='#000000' strokeWeight=1pt><v:stroke EndArrow='Classic'/></v:line>"
response.Write " <v:line ID='Y' from='1700,900' to='1700,10700' style='z-index:2' strokecolor='#000000' strokeWeight=1pt><v:stroke StartArrow='Classic'/></v:line>"

response.Write " <v:Rect style='position:relative;left:100;top:700;width:1500;height:500' filled='false' stroked='false'>"
response.Write " <v:TextBox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;'><div align='right'>"&Y_unit&"</div></v:TextBox>"
response.Write " </v:Rect> "
response.Write " <v:Rect style='position:relative;left:22200;top:11700;width:2000;height:500' filled='false' stroked='false'>"
response.Write " <v:TextBox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;'><div align='left'>"&X_unit&"</div></v:TextBox>"
response.Write " </v:Rect> "
for i=0 to num
response.Write " <v:line from='1200,"&i*1000+1700&"' to='1700,"&i*1000+1700&"' style='z-index:2' strokecolor='#000000'></v:line>"
response.Write " <v:line from='1700,"&i*1000+1700&"' to='2200,"&i*1000+1200&"' style='z-index:2' strokecolor='#0099FF'></v:line>"
response.Write " <v:line from='2200,"&i*1000+1200&"' to='22200,"&i*1000+1200&"' style='z-index:2' strokecolor='#0099FF'></v:line>"
response.Write " <v:line from='2200,"&i*1000+2200&"' to='22200,"&i*1000+2200&"' style='z-index:2' strokecolor='#0099FF'>"
response.Write " <v:stroke dashstyle='Dot'/>"
response.Write " </v:line>"

response.Write " <v:Rect style='position:relative;left:100;top:"&i*1000+1250&";width:1500;height:500' filled='false' stroked='false'>"
response.Write " <v:TextBox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;'><div align='right'>"&item_hight*(9-i)&"</div></v:TextBox>"
response.Write " </v:Rect> "
next

response.Write " <v:line from='2200,10700' to='22200,10700' style='z-index:2' strokecolor='#0099FF'></v:line>"
response.Write " <v:line from='2200,1200' to='2200,10700' style='z-index:2' strokecolor='#0099FF'></v:line>"
response.Write " <v:line from='1700,10700' to='2200,10700' style='z-index:2' strokecolor='#0099FF'></v:line>"

for i=1 to num
this_hight = cint(stat_array(i,1)/(9*item_hight)*10000+420)
response.Write " <v:shape id='Box"&i&"' type='#Box' fillcolor='"&bg_color(i)&"' strokecolor='#5f5f5f' style='position:relative; left:"&(i-1)*item_width+begin_x&";top:"&cint(10000-this_hight+620)&";width:1200;height:"&this_hight&";z-index:10'>"
response.Write " <v:fill o:opacity2='52429f' rotate='t' angle='-45' focus='100%' type='gradient'/>"
response.Write " </v:shape>"

response.Write " <v:Rect style='position:relative;left:"&(i-1)*item_width+2200&";top:"&cint(10000-this_hight+150)&";width:"&item_width&";height:500' filled='false' stroked='false'>"
response.Write " <v:TextBox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;'><div align='center'>"&stat_array(i,1)&"</div></v:TextBox>"
response.Write " </v:Rect> "

response.Write " <v:Rect style='position:relative;left:"&(i-1)*item_width+2200&";top:10850;width:"&item_width&";height:500' filled='false' stroked='false'>"
response.Write " <v:TextBox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;'><div align='center'>"&stat_array(i,2)&"</div></v:TextBox>"
response.Write " </v:Rect> "
next
response.Write "</v:group>"
end function
%>

原创粉丝点击