CSDN博客

img gengwei80

asp+VML统计图

发表于2004/10/9 10:28:00  1648人阅读

分类: XML & VML & SVG Asp

<script language="javascript">
function show(pie){
 pie.strokecolor=pie.fillcolor;
 pie.strokeweight=2;
}
function hide(pie){
 pie.strokecolor="white";
 pie.strokeweight=1;
}
function msg(pie){
  alert(pie.title);
  window.location.href="qx1.asp?id=1"
}
</script>
<style>
.PIE_TEXT {
 BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 11px; BACKGROUND: #ffffee; OVERFLOW: hidden; BORDER-LEFT: #cccccc 1px solid; ; WIDTH: expression(this.w = ((this.innerText.length>20)?100:(''))); PADDING-TOP: 2px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; LETTER-SPACING: 1px; POSITION: absolute; TEXT-OVERFLOW: ellipsis;
</style>
<%
dim tb_color(4,1)
tb_color(1,1)="#00ff00"
tb_color(2,1)="#ff0000"
tb_color(3,1)="#ff9900"
tb_color(4,1)="#33cccc"
connstr="DBQ="+server.mappath("../mess.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set Conn = server.CreateObject("ADODB.connection")
Conn.Open connstr
on error resume next
set rs= server.createobject("adodb.recordset")
rs.open "select title,point from title",Conn,1,1
if rs.eof and rs.bof then                 
   rs.close                 
else
redim total(rs.recordcount,1)
i=1
do while not rs.eof
 total(i,0)=rs.fields(0).value
 total(i,1)=rs.fields(1).value
 rs.movenext
 i = i + 1
loop
end if
%><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></head>
<body topmargin=5 leftmargin=0 scroll=AUTO onselectstart="return false" ondragstart="return false" oncontextmenu="return false">
<%call piepic(total,tb_color,150,100,250,250)%>
</body>
</html>
<%
function piepic(total,tb_color,table_x,table_y,all_width,all_height)
 tb_height=30
 total_no=ubound(total,1)
 totalpie=0
 for i=1 to total_no
  totalpie=totalpie+total(i,1)
 next
 PreAngle=0
 for i=1 to total_no
   response.write "<v:shape title='分类:"&total(i,0)&"&#10;数量:"&total(i,1)&"' onmouseover='show(this)' onmouseout='hide(this)' href='qx1.asp?id=1' id='_x0000_s1025' alt='' style='position:absolute;cursor:hand;left:"&table_x&"px;top:"&table_y&"px;width:"&all_width&"px;height:"&all_height&"px;z-index:1' coordsize='1500,1400' o:spt='100' adj='0,,0' path='m750,700ae750,700,750,700,"&int(23592960*PreAngle)&","&int(23592960*total(i,1)/totalpie)&"xe' fillcolor='"&tb_color(i,1)&"' strokecolor='#FFFFFF'><v:fill color2='"&tb_color(i,1)&"' rotate='t' focus='100%' type='gradient'/><v:stroke joinstyle='round'/><v:formulas/><v:path o:connecttype='segments'/></v:shape>"&CHr(13)
   PreAngle=PreAngle+total(i,1)/totalpie
 next
 pie=3.14159265358979
 TempPie=0
 for i=1 to total_no
   TempAngle=pie*2*(total(i,1)/(TotalPie*2)+TempPie)
   x1=table_x+all_width/2+cos(TempAngle)*all_width*3/8
   y1=table_y+all_height/2-sin(TempAngle)*all_height*3/8
   x2=table_x+all_width/2+cos(TempAngle)*all_width*3/4
   y2=table_y+all_height/2-sin(TempAngle)*all_height*3/4
   if x2>table_x+all_width/2 then
     x3=x2
     x4=x3
   else
     x3=x2-20
     x4=x3-60
   end if
   response.write "<v:line  id='_x0000_s1025' alt='' style='position:absolute;left:0;text-align:left;top:0;z-index:1' from='"&x1&"px,"&y1&"px' to='"&x2&"px,"&y2&"px' coordsize='21600,21600' strokecolor='"&tb_color(i,1)+"' strokeweight='1px'></v:line>"
   response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&x4&"px;top:"&y2-10&"px;width:110px;height:20px;z-index:1'>"
   response.write "<v:textbox class='PIE_TEXT' inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"&formatnumber(total(i,1)*100/totalpie,2,-1)&"% "&total(i,0)&"</td></tr></table></v:textbox></v:shape>"
   TempPie=TempPie+total(i,1)/TotalPie
  ' response.write TempPie&"<br>"
 next
end function
%>
阅读全文
0 0

相关文章推荐

img
取 消
img