您的位置:首页 > 编程语言 > VB

VML + VB实现线形统计图(1)

2008-03-14 15:27 615 查看
<%
'参数含义(数组,横坐标,纵坐标,图表的宽度,图表的高度,图表标题,X轴单位,Y轴单位)
function table1(stat_array,table_left,table_top,all_width,all_height,table_title,X_unit,Y_unit)
dim bg_color(10)
bg_color(1)="#ff1919"
bg_color(2)="#ffff19"
bg_color(3)="#1919ff"
bg_color(4)="#19ff19"
bg_color(5)="#fc0"
bg_color(6)="#3cc"
bg_color(7)="#ff19ff"
bg_color(8)="#993300"
bg_color(9)="#f60"
bg_color(10)="#ff8c19"
if X_unit <> "" then
X_unit = X_unit
end If
if Y_unit <> "" then
Y_unit = Y_unit
end if

num1 = ubound(stat_array,1)
line_temp=split(stat_array(0,1),",")
num2 = ubound(line_temp,1)+1
dim line_code
redim line_code(num1,num2)
for j=1 to num2
line_code(0,j) = line_temp(j-1)
Next

for i=1 to num1
line_temp = split(stat_array(i,1),",")
line_code(i,0) = stat_array(i,2)
for j=1 to num2
line_code(i,j) = cdbl(line_temp(j-1))
next
next
value_Max=0
for i=1 to num1
for j=1 to num2
if value_Max<line_code(i,j) then value_Max=line_code(i,j)
next
next
value_Max = cint(value_Max)
value_Max_str =cstr(value_Max)
if value_Max>9 then
temp=mid(value_Max_str,2,1)
if temp>4 then
temp2=(int(value_Max/(10^(len(value_Max_str)-1)))+1)*10^(len(value_Max_str)-1)
else
temp2=(int(value_Max/(10^(len(value_Max_str)-1)))+0.5)*10^(len(value_Max_str)-1)
end if
Else
if value_Max>4 then temp2=10 else temp2=5
end If
item_hight = temp2/5
item_width = 20000/(num2-1)
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 = '27500,12800'>"
response.Write " <v:Rect style='position:relative;left:1500;top:200;width:23000;height:800'filled='false' stroked='f'>"
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:15pt; 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:10500;' fillcolor='#9cf' strokecolor='#DFDFDF'>"
response.Write " <v:fill rotate='t' angle='-45' focus='100%' type='gradient'/>"
response.Write " </v:rect>"
response.Write " <v:rect id='back2' style='position:relative;left:23000;top:1200;width:4000; height:"&(10500)&";' fillcolor='#9cf' stroked='t' strokecolor='#0099ff'>"
response.Write " <v:fill rotate='t' angle='-175' focus='100%' type='gradient'/>"
response.Write " <v:shadow on='t' type='single' color='silver' offset='3pt,3pt'/>"
response.Write " </v:rect>"
for i=1 to num1
if i=1 then
displaystr=""
else
displaystr="none"
end If
response.Write " <div style='cursor:hand;' onmouseover='moveon(rec"&i&",line_"&i&")' onmouseout='moveout(rec"&i&",line_"&i&","&i&")' onclick='clickit("&i&")'>"
response.Write " <v:Rect id='rec"&i&"' style='position:relative;left:23100;top:"&(i-1)*10200/10+1450&";width:3800;height:800;display:"&displaystr&";' fillcolor='#efefef' strokecolor='"&bg_color(i)&"'>"
response.Write " <v:fill opacity='.6' color2='fill darken(118)' o:opacity2='.6' rotate='t' method='linear sigma' focus='100%' type='gradient'/>"
response.Write " </v:Rect>"
response.Write " <v:Rect style='position:relative;left:23200;top:"&(i-1)*10200/10+1500&";width:600;height:700' fillcolor='"&bg_color(i)&"' stroked='f'/>"
response.Write " <v:Rect style='position:relative;left:24000;top:"&(i-1)*10200/10+1500&";width:3400;height:700' filled='f' stroked='f'>"
response.Write " <v:TextBox inset='0pt,4pt,0pt,0pt' style='font-size:9pt;'><div align='left'>"&stat_array(i,2)&"</div></v:TextBox>"
response.Write " </v:Rect> "
response.Write " </div> "
next
response.Write " <v:line ID='X' from='1700,11700' to='22700,11700' 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,11700' 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:11900;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 4
response.Write " <v:line from='1300,"&i*2000+1700&"' to='1700,"&i*2000+1700&"' style='z-index:2' strokecolor='#000000'></v:line>"
response.Write " <v:line from='1700,"&i*2000+1700&"' to='2200,"&i*2000+1200&"' style='z-index:2' strokecolor='#0099FF'></v:line>"
response.Write " <v:line from='2200,"&i*2000+1200&"' to='22200,"&i*2000+1200&"' style='z-index:2' strokecolor='#0099FF'></v:line>"
response.Write " <v:line from='2200,"&i*2000+2200&"' to='22200,"&i*2000+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*2000+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*(5-i)&"</div></v:TextBox>"
response.Write " </v:Rect> "
next
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: