C#三维饼图

来源:互联网 发布:知党情感党恩跟党走 编辑:程序博客网 时间:2024/04/28 10:09

<% @ Page Language="C#" %> <% @ Page Language="C#" %>
<script language="C#" runat="server">
public void table2(string[,] stat_array,int table_left,int table_top,int all_width,int all_height,string table_title,string unit)
{
string[] bg_color=new string[10];
double[] pie=new double[11];
bg_color[0]="#ff1919";
bg_color[1]="#ffff19";
bg_color[2]="#1919ff";
bg_color[3]="#19ff19";
bg_color[4]="#fc0";
bg_color[5]="#3cc";
bg_color[6]="#ff19ff";
bg_color[7]="#993300";
bg_color[8]="#f60";
bg_color[9]="#ff8c19";

int num =stat_array.GetLength(0);
int allvalues=0;
for(int i=0;i<num;i++)
{
allvalues = allvalues+int.Parse(stat_array[i,0]);
}
double k=0;
for(int i=0;i<num;i++)
{
pie[i]=double.Parse(String.Format("{0:F4}",(int.Parse(stat_array[i,0])/(allvalues+0.0))));
}
//pie[9]=double.Parse(String.Format("{0:F4}",(int.Parse(stat_array[9,0])/(allvalues+0.0))));
for(int i=0;i<num-1;i++)
{
k=k+pie[i];
}
pie[num]=(1-k);

///////////////////////////////////////
Response.Write( "<v:shapetype id='Cake_3D' coordsize='21600,21600' o:spt='95' adj='11796480,5400' path='al10800,10800@0@0@2@14,10800,10800,10800,10800@3@15xe'></v:shapetype>");

Response.Write( "<v:shapetype id='3dtxt' coordsize='21600,21600' o:spt='136' adj='10800' path='m@7,l@8,m@5,21600l@6,21600e'> ");
Response.Write( " <v:path textpathok='t' o:connecttype='custom' o:connectlocs='@9,0;@10,10800;@11,21600;@12,10800' o:connectangles='270,180,90,0'/>");
Response.Write( " <v:textpath on='t' fitshape='t'/>");
Response.Write( " <o:lock v:ext='edit' text='t' shapetype='t'/>");
Response.Write( "</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 = '21000,11500'>");
Response.Write( " <v:Rect style='position:relative;left:500;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: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:500;top:1000;width:20000; height:10000;' onmouseover='movereset(1)' onmouseout='movereset(0)' fillcolor='#9cf' strokecolor='#888888'>");
Response.Write( " <v:fill rotate='t' angle='-45' focus='100%' type='gradient'/>");
Response.Write( " </v:rect>");

Response.Write( " <v:rect id='back' style='position:relative;left:15000;top:1400;width:5000; height:"+((num+1)*9000/11+200)+";' 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>");

Response.Write( " <v:Rect style='position:relative;left:15500;top:1500;width:4000;height:700' fillcolor='#000000' stroked='f' strokecolor='#000000'>");
Response.Write( " <v:TextBox inset='8pt,4pt,3pt,3pt' style='font-size:11pt;'><div align='left'><font color='#ffffff'><B>总数:"+allvalues+unit+"</B></font></div></v:TextBox>");
Response.Write( " </v:Rect> ");
for(int i=1;i<=num;i++)
{
Response.Write( " <v:Rect id='rec"+i+"' style='position:relative;left:15400;top:"+(i*9000.0/11.0+1450)+";width:4300;height:800;display:none' fillcolor='#efefef' strokecolor='"+bg_color[i-1]+"'>");
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:15500;top:"+(i*9000/11.0+1500)+";width:600;height:700' fillcolor='"+bg_color[i-1]+"' stroked='f'/>");
Response.Write( " <v:Rect style='position:relative;left:16300;top:"+(i*9000/11.0+1500)+";width:3400;height:700' filled='f' stroked='f'>");
Response.Write( " <v:TextBox inset='0pt,5pt,0pt,0pt' style='font-size:9pt;'><div align='left'>"+stat_array[i-1,1]+":"+stat_array[i-1,0]+unit+"</div></v:TextBox>");
Response.Write( " </v:Rect> ");
}

Response.Write( "</v:group>");;
////////////////////////////////////////
double k1=180;
double k4=10;
double k3=0;
double k2=0;
double k5=0;
for(int i=1;i<=num;i++){
k2=360*pie[i-1]/2;
k3=k1+k2;
if (k3>=360)
k3=k3-360;
double kkk=(-11796480*pie[i-1]+5898240);

k5=3.1414926*2*(180-(k3-180))/360;
int R=all_height/2;
double txt_x = table_left+all_height/8-30+R+R*Math.Sin(k5)*0.7;
double txt_y = table_top+all_height/14-39+R+R*Math.Cos(k5)*0.7*0.5;
////////////////////////////////////////
string titlestr = "&nbsp;名&nbsp;&nbsp;称:"+stat_array[i-1,1]+"&#13;&#10;&nbsp;数&nbsp;&nbsp;值:"+stat_array[i-1,0]+unit+"&#13;&#10;&nbsp;所占比例:"+pie[i-1]*100+"%&nbsp;&nbsp;";
//Response.Write(pie[i-1]);
Response.Write( " <div style='cursor:hand;'>");
Response.Write( " <v:shape id='cake"+i+"' type='#Cake_3D' title='"+titlestr+"'");
Response.Write( " style='position:absolute;left:"+(table_left+all_height/8)+"px;top:"+(table_top+all_height/14)+"px;WIDTH:"+all_height+"px;HEIGHT:"+all_height+"px;rotation:"+k3+";z-index:"+k4+"'");
Response.Write( " adj='"+kkk+",0' fillcolor='"+bg_color[i-1]+"' onmouseover='moveup(cake"+i+","+(table_top+all_height/14)+",txt"+i+",rec"+i+")'; onmouseout='movedown(cake"+i+","+(table_top+all_height/14)+",txt"+i+",rec"+i+");'>");
Response.Write( " <v:fill opacity='60293f' color2='fill lighten(120)' o:opacity2='60293f' rotate='t' angle='-135' method='linear sigma' focus='100%' type='gradient'/>");
Response.Write( " <o:extrusion v:ext='view' on='t'backdepth='25' rotationangle='60' viewpoint='0,0'viewpointorigin='0,0' skewamt='0' lightposition='-50000,-50000' lightposition2='50000'/>");
Response.Write( " </v:shape>");
Response.Write( " <v:shape id='txt"+i+"' type='#3dtxt' style='position:absolute;left:"+txt_x+"px;top:"+txt_y+"px;z-index:20;display:none;width:50; height:18;' fillcolor='#ffffff'");
Response.Write( " onmouseover='ontxt(cake"+i+","+(table_top+all_height/14)+",txt"+i+",rec"+i+")'>");
Response.Write( " <v:fill opacity='60293f' color2='fill lighten(120)' o:opacity2='60293f' rotate='t' angle='-135' method='linear sigma' focus='100%' type='gradient'/>");
Response.Write( " <v:textpath style='font-family:'宋体';v-text-kern:t' trim='t' fitpath='t' string='"+(pie[i-1]*100)+"%'/>");
Response.Write( " <o:extrusion v:ext='view' backdepth='8pt' on='t' lightposition='0,0' lightposition2='0,0'/>");
Response.Write( " </v:shape>");
Response.Write( " </div>");
k1=k1+k2*2;
if(k1>=360)k1=k1-360;
if(k1>180)k4=k4+1;
else k4=k4-1;
}
}

</script>


<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title></title>
<STYLE>
v/:* { Behavior: url(#default#VML) }
o/:* { behavior: url(#default#VML) }
</STYLE>
</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
<!--
onit=true
num=0
function moveup(iteam,top,txt,rec){
temp=eval(iteam)
tempat=eval(top)
temptxt=eval(txt)
temprec=eval(rec)
at=parseInt(temp.style.top)
temprec.style.display = "";
if (num>27){
temptxt.style.display = "";
}
if(at>(tempat-28)&&onit){
num++
temp.style.top=at-1
Stop=setTimeout("moveup(temp,tempat,temptxt,temprec)",10)
}else{
return
}
}
function movedown(iteam,top,txt,rec){
temp=eval(iteam)
temptxt=eval(txt)
temprec=eval(rec)
clearTimeout(Stop)
temp.style.top=top
num=0
temptxt.style.display = "none";
temprec.style.display = "none";
}
function ontxt(iteam,top,txt,rec){
temp = eval(iteam);
temptxt = eval(txt);
temprec = eval(rec)
if (onit){
temp.style.top = top-28;
temptxt.style.display = "";
temprec.style.display = "";
}
}
function movereset(over){
if (over==1){
onit=false
}else{
onit=true
}
}
-->
</script>
<%
string[,] total=new string[10,2];

total[0,0]="2000";
total[1,0]="1800";
total[2,0]="1700";
total[3,0]="1500";
total[4,0]="1222";
total[5,0]="1100";
total[6,0]="1000";
total[7,0]="800";
total[8,0]="700";
total[9,0]="600";

total[0,1]="项目1";
total[1,1]="项目2";
total[2,1]="项目3";
total[3,1]="项目4";
total[4,1]="项目5";
total[5,1]="项目6";
total[6,1]="项目7";
total[7,1]="项目8";
total[8,1]="项目9";
total[9,1]="项目10";

table2(total,240,200,700,400,"三维饼状图","元");
%>
</body>
</html>
<%string[,] total=new string[10,2];total[0,0]="2000";total[1,0]="1800";total[2,0]="1700";total[3,0]="1500";total[4,0]="1222";total[5,0]="1100";total[6,0]="1000";total[7,0]="800";total[8,0]="700";total[9,0]="600";total[0,1]="项目1";total[1,1]="项目2";total[2,1]="项目3";total[3,1]="项目4";total[4,1]="项目5";total[5,1]="项目6";total[6,1]="项目7";total[7,1]="项目8";total[8,1]="项目9";total[9,1]="项目10";table2(total,240,200,700,400,"三维饼状图","元");%><% @ Page Language="C#" %><% @ Page Language="C#" %><% @ Page Language="C#" %><% @ Page Language="C#" %><%string[,] total=new string[10,2];total[0,0]="2000";total[1,0]="1800";total[2,0]="1700";total[3,0]="1500";total[4,0]="1222";total[5,0]="1100";total[6,0]="1000";total[7,0]="800";total[8,0]="700";total[9,0]="600";total[0,1]="项目1";total[1,1]="项目2";total[2,1]="项目3";total[3,1]="项目4";total[4,1]="项目5";total[5,1]="项目6";total[6,1]="项目7";total[7,1]="项目8";total[8,1]="项目9";total[9,1]="项目10";table2(total,240,200,700,400,"三维饼状图","元");%><%string[,] total=new string[10,2];total[0,0]="2000";total[1,0]="1800";total[2,0]="1700";total[3,0]="1500";total[4,0]="1222";total[5,0]="1100";total[6,0]="1000";total[7,0]="800";total[8,0]="700";total[9,0]="600";total[0,1]="项目1";total[1,1]="项目2";total[2,1]="项目3";total[3,1]="项目4";total[4,1]="项目5";total[5,1]="项目6";total[6,1]="项目7";total[7,1]="项目8";total[8,1]="项目9";total[9,1]="项目10";table2(total,240,200,700,400,"三维饼状图","元");%><%string[,] total=new string[10,2];total[0,0]="2000";total[1,0]="1800";total[2,0]="1700";total[3,0]="1500";total[4,0]="1222";total[5,0]="1100";total[6,0]="1000";total[7,0]="800";total[8,0]="700";total[9,0]="600";total[0,1]="项目1";total[1,1]="项目2";total[2,1]="项目3";total[3,1]="项目4";total[4,1]="项目5";total[5,1]="项目6";total[6,1]="项目7";total[7,1]="项目8";total[8,1]="项目9";total[9,1]="项目10";table2(total,240,200,700,400,"三维饼状图","元");%><%string[,] total=new string[10,2];total[0,0]="2000";total[1,0]="1800";total[2,0]="1700";total[3,0]="1500";total[4,0]="1222";total[5,0]="1100";total[6,0]="1000";total[7,0]="800";total[8,0]="700";total[9,0]="600";total[0,1]="项目1";total[1,1]="项目2";total[2,1]="项目3";total[3,1]="项目4";total[4,1]="项目5";total[5,1]="项目6";total[6,1]="项目7";total[7,1]="项目8";total[8,1]="项目9";total[9,1]="项目10";table2(total,240,200,700,400,"三维饼状图","元");%>

原创粉丝点击