javascript结合php生成统计图(饼形,折线,柱状)
来源:互联网 发布:win10安装外部软件 编辑:程序博客网 时间:2024/06/15 04:08
<?
require_once("global.php");
$objDb_Sql1=new Db_Sql();
$objDb_Sql1->connect($cfg_mysql_database);
?>
<script language="javascript" type="text/javascript">
<!--
//=============调用方法=====================
function getdata_and_name3(data,name){
var dataArray = data.split(",");
var nameArray = name.split(",");
var total1= new Array(nameArray,dataArray);
//table3(total1,100,100,250,250,"A");
table3(total1,400,590,250,250,"B");
}
function table3(total,table_x,table_y,all_width,all_height,table_type)
{
//参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,图表的类型)
var tmdColor1 = new Array();
tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";
tmdColor1[7] = "#97bd00";
tmdColor1[8] = "#009900";
tmdColor1[9] = "#cc3300";
tmdColor1[10] = "#ffcc00";
tmdColor1[11] = "#3366cc";
tmdColor1[12] = "#33cc33";
tmdColor1[13] = "#ff9933";
tmdColor1[14] = "#cccc99";
tmdColor1[15] = "#99cc66";
tmdColor1[16] = "#66ff99";
tmdColor1[17] = "#4f6600";
tmdColor1[18] = "#481000";
tmdColor1[19] = "#7d6400";
tmdColor1[20] = "#173064";
tmdColor1[21] = "#173064";
tmdColor1[22] = "#1a6a1a";
tmdColor1[23] = "#974b00";
tmdColor1[24] = "#78793c";
tmdColor1[25] = "#557e27";
tmdColor1[26] = "#009337";
var tmdColor2 = new Array();
tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";
tmdColor2[7] = "#97bd00";
tmdColor2[8] = "#009900";
tmdColor2[9] = "#cc3300";
tmdColor2[10] = "#ffcc00";
tmdColor2[11] = "#3366cc";
tmdColor2[12] = "#33cc33";
tmdColor2[13] = "#ff9933";
tmdColor2[14] = "#cccc99";
tmdColor2[15] = "#99cc66";
tmdColor2[16] = "#66ff99";
tmdColor2[17] = "#4f6600";
tmdColor2[18] = "#481000";
tmdColor2[19] = "#7d6400";
tmdColor2[20] = "#173064";
tmdColor2[21] = "#173064";
tmdColor2[22] = "#1a6a1a";
tmdColor2[23] = "#974b00";
tmdColor2[24] = "#78793c";
tmdColor2[25] = "#557e27";
tmdColor2[26] = "#009337";
var tb_color = new Array(tmdColor1,tmdColor2);
var tb_height = 30;
var total_no = total[0].length;
var totalpie = 0;
for(var i=0;i<total_no;i++)
{
total[1][i]*=100;
totalpie += total[1][i];
}
var PreAngle = 0;
for(var i=0;i<total_no;i++)
{
document.write("<v:shape id='_x0000_s1025' alt='' style='position:absolute;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," + parseInt(23592960*PreAngle) + "," + parseInt(23592960*total[1][i]/totalpie) + "xe' fillcolor='" + tb_color[0][i] + "' strokecolor='#FFFFFF'><v:fill color2='" + tb_color[1][i] + "' rotate='t' focus='100%' type='gradient'/><v:stroke joinstyle='round'/><v:formulas/><v:path o:connecttype='segments'/></v:shape>");
PreAngle += total[1][i] / totalpie;
}
if(table_type=="A")
{
document.write("<v:rect id='_x0000_s1025' style='position:absolute;left:" + (table_x + all_width + 20) + "px;top:" + (table_y + 20) + "px;width:100px;height:" + (total_no * tb_height + 20) + "px;z-index:1'/>");
for(var i=0;i<total_no;i++)
{
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x + all_width + 25) + "px;top:" + (table_y+30+(i)*tb_height) + "px;width:60px;height:" + tb_height + "px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:rect id='_x0000_s1040' alt='' style='position:absolute;left:" + (table_x + all_width + 80) + "px;top:" + (table_y + 30 + (i)*tb_height+3) + "px;width:30px;height:20px;z-index:1' fillcolor='" + tb_color[0][i] + "'><v:fill color2='" + tb_color[1][i] + "' rotate='t' focus='100%' type='gradient'/></v:rect>");
//显示比例数
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x+all_width+110) + "px;top:" + (table_y+30+(i)*tb_height) + "px;width:60px;height:" + tb_height + "px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + Math.round(parseFloat(total[1][i]*100/totalpie)*100)/100 + "%</td></tr></table></v:textbox></v:shape>");
}
}
if(table_type == "B")
{
var pie = 3.14159265358979;
var TempPie = 0;
for(var i=0;i<total_no;i++)
{
var TempAngle = pie * 2 * (total[1][i] / (totalpie * 2) + TempPie);
var x1 = table_x + all_width/2 + Math.cos(TempAngle) * all_width * 3/8;
var y1 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/8;
var x2 = table_x + all_width/2 + Math.cos(TempAngle) * all_width * 3/4;
var y2 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/4;
if(x2>table_x + all_width/2)
{
x3 = x2 + 20;
x4 = x3;
}
else
{
x3 = x2 - 20;
x4 = x3 - 100;
}
document.write("<v:oval id='_x0000_s1027' style='position:absolute;left:" + (x1 - 2) + "px;top:" + (y1 - 2) + "px;width:4px;height:4px; z-index:2' fillcolor='#111111' strokecolor='#111111'/>");
document.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='#111111' strokeweight='1px'></v:line>");
document.write("<v:line id='_x0000_s1025' alt='' style='position:absolute;left:0;text-align:left;top:0;z-index:1' from='" + x2 + "px," + y2 + "px' to='" + x3 + "px," + y2 + "px' coordsize='21600,21600' strokecolor='#111111' strokeweight='1px'></v:line>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + x4 + "px;top:" + (y2 - 10) + "px;width:100px;height:20px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + total[0][i] + " " + Math.round(parseFloat(total[1][i] * 100/ totalpie)*100)/100 + "%</td></tr></table></v:textbox></v:shape>")
TempPie += total[1][i]/totalpie;
}
}
}
//-->
</script>
<script language=javascript>
function getdata_and_name2(data,name){
var dataArray2 = new Array()
var dataArray =data.split(",");
var nameArray =name.split(",");
dataArray2[0]="#0000FF,1,2,3,"+dataArray[0];
for(var i=1;i<=dataArray.length-1;i++){
dataArray2[i]=dataArray[i]*10;
}
var total =new Array(nameArray,dataArray2);
table2(total,70,980,804,200,1);
}
function table2(total,table_x,table_y,all_width,all_height,line_no)
{
//参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,折线条数)
//纯ASP代码生成图表函数2——折线图
//作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@sina.com Email:passwordgm@sina.com
//本人非常愿意和ASP,VML,FLASH的爱好者在HTTP://topclouds.126.com进行交流和探讨
//版本1.0 最后修改日期 2003-8-11
//非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。
//***************************************************************************************
//修改说明:
// 本代码经原作者同意,由 awaysrain(绝对零度)修改为javascript。
// 最后修改日期 2003-9-22,测试环境为IE 6.0.2500.1106
// 因本人水平有限,修改中难免有错误,请大家及时指正。
//***************************************************************************************
var line_color = "#69f";
var left_width = 70;
var total_no = total[1].length
var temp1,temp2,temp3
temp1 = 0;
for(var i=1;i<total_no;i++)
{
for(var j=1;j<=line_no;j++)
{
if(temp1<total[j][i])
temp1 = total[j][i];
}
}
temp1 = parseInt(temp1);
if(temp1>9)
{
temp2 = temp1.toString().substr(1,1);
if(temp2>4)
{
temp3 = (parseInt(temp1/(Math.pow(10,(temp1.toString().length-1))))+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (praseInt(temp1/(Math.pow(10,(temp1.toString().length-1))))+0.5)*Math.pow(10,(temp1.toString().length-1))
}
}
else
{
if(temp1>4)
{
emp3 = 10;
}
else
{
temp3 = 5;
}
}
temp4 = temp3;
document.write("<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>");
for(var i=0;i<all_height;i += all_height/5)
{
document.write("<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 + "'/>");
document.write("<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'/>");
document.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'>");
document.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>");
temp4 = temp4 - temp3/5;
}
document.write("<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'/>");
document.write("<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'/>");
var tmpStr = ""
for(i=1;i<=line_no;i++)
{
var re = /,/g;
tmpStr += ",[/"" + total[i][0].replace(re,"/",/"") + "/"]"
}
tmpStr = tmpStr.substr(1,tmpStr.length-1)
var line_code = eval("new Array(" + tmpStr + ")")
for(var j=1;j<=line_no;j++)
{
for(var i=1;i<total_no-1;i++)
{
var x1 = table_x + left_width + all_width * (i - 1)/(total_no-1)
var y1 = table_y + (temp3 - total[j][i]) * (all_height/temp3)
var x2 = table_x + left_width + all_width * i/(total_no-1)
var y2 = table_y + (temp3 - total[j][i+1]) * (all_height/temp3)
document.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='" + line_code[j-1][0] + "' strokeweight='" + line_code[j-1][1] + "'>");
switch (parseInt(line_code[j-1][2]))
{
case 1:
break;
case 2:
document.write("<v:stroke dashstyle='1 1'/>");
break;
case 3:
document.write("<v:stroke dashstyle='dash'/>");
break;
case 4:
document.write("<v:stroke dashstyle='dashDot'/>");
break;
case 5:
document.write("<v:stroke dashstyle='longDash'/>");
break;
case 6:
document.write("<v:stroke dashstyle='longDashDot'/>");
break;
case 7:
document.write("<v:stroke dashstyle='longDashDotDot'/>");
break;
}
document.write("</v:line>");
switch (parseInt(line_code[j-1][3]))
{
case 1:
break;
case 2:
document.write("<v:rect id='_x0000_s1027' style='position:absolute;left:" + (x1 - 2) + "px;top:" + (y1 - 2) + "px;width:4px;height:4px; z-index:2' fillcolor='" + line_code[j-1][0] + "' strokecolor='" + line_code[j-1][0] + "'/>");
break;
case 3:
document.write("<v:oval id='_x0000_s1026' style='position:absolute;left:" + (x1 - 2) + "px;top:" + (y1 - 2) + "px;width:4px;height:4px;z-index:1' fillcolor='" + line_code[j-1][0] + "' strokecolor='" + line_code[j-1][0] + "'/>");
break;
}
}
switch (parseInt(line_code[j-1][3]))
{
case 1:
break;
case 2:
document.write("<v:rect id='_x0000_s1027' style='position:absolute;left:" + (x2 - 2) + "px;top:" + (y2 - 2) + "px;width:4px;height:4px; z-index:2' fillcolor='" + line_code[j-1][0] + "' strokecolor='" + line_code[j-1][0] + "'/>");
break;
case 3:
document.write("<v:oval id='_x0000_s1026' style='position:absolute;left:" + (x2 - 2) + "px;top:" + (y2 - 2) + "px;width:4px;height:4px;z-index:1' fillcolor='" + line_code[j-1][0] + "' strokecolor='" + line_code[j-1][0] + "'/>");
break;
}
}
for(var i=0;i<total_no-1;i++)
{
document.write("<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 + all_width * (i)/(total_no-1)) + "px," + (table_y + all_height) + "px' to='" + (table_x + left_width + all_width * (i)/(total_no-1)) + "px," + (table_y + all_height + 15) + "px'/>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x + left_width + all_width * (i)/(total_no-1)) + "px;top:" + (table_y + all_height) + "px;width:" + (all_width/(total_no-1)) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
}
var tb_height = 30
document.write("<v:rect id='_x0000_s1025' style='position:absolute;left:" + (table_x + all_width + 20) + "px;top:" + table_y + "px;width:100px;height:" + (line_no * tb_height + 20) + "px;z-index:1'/>");
for(var i=0;i<line_no;i++)
{
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x + all_width + 25) + "px;top:" + (table_y + 10+(i) * tb_height) + "px;width:60px;height:" + tb_height + "px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + line_code[i][4] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:rect id='_x0000_s1040' alt='' style='position:absolute;left:" + (table_x + all_width + 80) + "px;top:" + (table_y + 10+(i) * tb_height + 4) + "px;width:30px;height:20px;z-index:1' fillcolor='" + line_code[i][0] + "'><v:fill color2='" + line_code[i][0] + "' rotate='t' focus='100%' type='gradient'/></v:rect>");
}
}
</script>
<script language=javascript>
function getdata_and_name1(data,name){
var dataArray =data.split(",");
var nameArray =name.split(",");
var total =new Array(dataArray,nameArray);
table1(total,70,350,20,30,800,100,"A");
}
function table1(total,table_x,table_y,thickness,table_width,all_width,all_height,table_type){
//参数含义(传递的数组,横坐标,纵坐标,柱子的厚度,柱子的宽度,图表的宽度,图表的高度,图表的类型)
//纯ASP代码生成图表函数1——柱状图
//作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@sina.com Email:passwordgm@sina.com
//本人非常愿意和ASP,VML,FLASH的爱好者在HTTP://topclouds.126.com进行交流和探讨
//版本2.0 最后修改日期 2003-7-22
//非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。
//***************************************************************************************
//修改说明:
// 本代码经原作者同意,由 awaysrain(绝对零度)修改为javascript。
// 最后修改日期 2003-9-22,测试环境为IE 6.0.2500.1106
// 因本人水平有限,修改中难免有错误,请大家及时指正。
//***************************************************************************************
var tmdColor1 = new Array();
tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";
tmdColor1[7] = "#97bd00";
tmdColor1[8] = "#009900";
tmdColor1[9] = "#cc3300";
tmdColor1[10] = "#ffcc00";
tmdColor1[11] = "#3366cc";
tmdColor1[12] = "#33cc33";
tmdColor1[13] = "#ff9933";
tmdColor1[14] = "#cccc99";
tmdColor1[15] = "#99cc66";
tmdColor1[16] = "#66ff99";
tmdColor1[17] = "#4f6600";
tmdColor1[18] = "#481000";
tmdColor1[19] = "#7d6400";
tmdColor1[20] = "#173064";
tmdColor1[21] = "#173064";
tmdColor1[22] = "#1a6a1a";
tmdColor1[23] = "#974b00";
tmdColor1[24] = "#78793c";
tmdColor1[25] = "#557e27";
tmdColor1[26] = "#009337";
var tmdColor2 = new Array();
tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";
tmdColor2[7] = "#97bd00";
tmdColor2[8] = "#009900";
tmdColor2[9] = "#cc3300";
tmdColor2[10] = "#ffcc00";
tmdColor2[11] = "#3366cc";
tmdColor2[12] = "#33cc33";
tmdColor2[13] = "#ff9933";
tmdColor2[14] = "#cccc99";
tmdColor2[15] = "#99cc66";
tmdColor2[16] = "#66ff99";
tmdColor2[17] = "#4f6600";
tmdColor2[18] = "#481000";
tmdColor2[19] = "#7d6400";
tmdColor2[20] = "#173064";
tmdColor2[21] = "#173064";
tmdColor2[22] = "#1a6a1a";
tmdColor2[23] = "#974b00";
tmdColor2[24] = "#78793c";
tmdColor2[25] = "#557e27";
tmdColor2[26] = "#009337";
var tb_color = new Array(tmdColor1,tmdColor2);
var line_color = "#69f";
var left_width = 70;
var length = thickness/2;
var total_no = total[0].length;
var temp1 = 0;
var temp2,temp4,temp4;
for(var i = 0;i<total_no;i++)
{
if(temp1<total[0][i])
{
temp1 = total[0][i];
}
}
temp1 = parseInt(temp1.toString());
if(temp1>9)
{
temp2 = temp1.toString().substr(1,1)
if(temp2>4)
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
}
}
else
{
if(temp1>4)
temp3 = 10;
else
temp3 = 5;
}
temp4=temp3
document.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]-->");
document.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]-->");
document.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]-->");
switch (table_type)
{
case "A":
var table_space = (all_width-table_width*total_no)/total_no;
document.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]-->");
for(var i=0;i<=all_height-1;i+= all_height/5)
{
document.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]-->");
document.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]-->");
document.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]-->");
document.write("<!--[if gte vml 1]>");
document.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'>");
document.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]-->");
temp4 = temp4-temp3/5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_x + left_width + table_space / 2 + table_space * i + table_width * i;
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(temp_space);
document.write("px;top:");
document.write(table_y + all_height * (1 - (total[0][i] / temp3)));
document.write("px;width:" + table_width + "px;height:" + all_height * (total[0][i] / temp3) + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' type='gradient'/>")
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + temp_space + "px;top:" + (table_y+all_height*(1-(total[0][i]/temp3))-table_width) + "px;width:" + (table_space+15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.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'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
break;
case "B":
var table_space = (all_height - table_width * total_no) / total_no;
document.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]-->");
for(var i=0;i<=all_width-1;i +=all_width/5)
{
document.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]-->");
document.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]-->");
document.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]-->");
document.write("<!--[if gte vml 1]>");
document.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'>");
document.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]-->");
temp4 = temp4 - temp3 / 5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_space/2 + table_space * i + table_width * i;
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(table_x + left_width);
document.write("px;top:");
document.write(table_y + temp_space);
document.write("px;width:" + all_width * (total[0][i] / temp3) + "px;height:" + table_width + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' angle='-90' focus='100%' type='gradient'/>");
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x + left_width + all_width * (total[0][i] / temp3) + thickness / 2) + "px;top:" + (table_y + temp_space) + "px;width:" + (table_space + 15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.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'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
}
}
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function viewYear()
{
var url;
var objDropYear = document.getElementById('drop_year3');
url="stat.php?y="+objDropYear.options(objDropYear.selectedIndex).value;
window.location.href=url;
}
function viewDepartment()
{
var url;
var objDropYearStart = document.getElementById('drop_year1_start');
var objDropYearEnd = document.getElementById('drop_year1_end');
var objDropMonthStart = document.getElementById('drop_month1_start');
var objDropMonthEnd = document.getElementById('drop_month1_end');
url="stat.php?c=d&s="+objDropYearStart.options(objDropYearStart.selectedIndex).value+objDropMonthStart.options(objDropMonthStart.selectedIndex).value+"&e="+objDropYearEnd.options(objDropYearEnd.selectedIndex).value+objDropMonthEnd.options(objDropMonthEnd.selectedIndex).value;
window.location.href=url;
}
//-->
</script>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[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">
<div style="position:absolute;left:70px;width:804px;"><img src="images/span_commom.jpg" width="804" height="4" border="0"></div>
<div style="position:absolute;left:140px;top:150px;width:804px;text-align:center;" class="td_tableheader" >信息与网络中心信息管理部服务统计</div>
<!-- 统计开始 -->
<?
$strStartYear = "2006";
$strEndYear = date("Y");
$strStartMonth = "12";
$strEndMonth = date("m");
if($_GET["c"] = "d" && !empty($_GET["s"]) && !empty($_GET["e"]))
{
$strStartYear = substr($_GET["s"],0,4);
$strEndYear = substr($_GET["e"],0,4);
$strStartMonth = substr($_GET["s"],4);
$strEndMonth = substr($_GET["e"],4);
}
if($strStartYear.$strStartMonth > date("Ym") || $strStartYear.$strStartMonth > $strEndYear.$strEndMonth)
{
echo '<div style="color:red;">对不起,您选择的开始年月或结束年月不合理,请重新选择</div>';
$strStartYear = "2006";
$strEndYear = date("Y");
$strStartMonth = "12";
$strEndMonth = date("m");
}
?>
<div style="position:absolute;left:310px;top:180px;font-size:16px;color:red; text-align:center;">
<select size="1" name="drop_year1_start" id="drop_year1_start">
<?
for($year = 2006; $year <= date("Y"); $year++)
{
echo '<option value="'.$year.'"';
if($year == $strStartYear)
{
echo " selected";
}
echo '>'.$year.'</option>';
}
?>
</select>年
<select size="1" name="drop_month1_start" id="drop_month1_start">
<?
for($month = 1; $month <= 12; $month++)
{
$strMonthValue = $month < 10 ? "0".$month : $month;
echo '<option value="'.$strMonthValue.'"';
if($month == $strStartMonth)
{
echo " selected";
}
echo '>'.$month.'</option>';
}
?>
</select>月 至
<select size="1" name="drop_year1_end" id="drop_year1_end">
<?
for($year = 2006; $year <= date("Y"); $year++)
{
echo '<option value="'.$year.'"';
if($year == $strEndYear)
{
echo " selected";
}
echo '>'.$year.'</option>';
}
?>
</select>年
<select size="1" name="drop_month1_end" id="drop_month1_end">
<?
for($month = 1; $month <= 12; $month++)
{
$strMonthValue = $month < 10 ? "0".$month : $month;
echo '<option value="'.$strMonthValue.'"';
if($month == $strEndMonth)
{
echo " selected";
}
echo '>'.$month.'</option>';
}
?>
</select>月 服务统计 <input type="button" onclick="viewDepartment()" value="查看" />
</div>
<br />
<!-- 年度统计 -->
<div style="font-size:16px;color:red;text-align:center;position:absolute;left:430px;top:930px;">
<select size="1" name="drop_year3" id="drop_year3">
<?
$strViewYear = date("Y");
if(!empty($_GET["y"]))
{
$strViewYear = $_GET["y"];
}
for($year = 2006; $year <= date("Y"); $year++)
{
echo '<option value="'.$year.'"';
if($year == $strViewYear)
{
echo " selected";
}
echo '>'.$year.'</option>';
}
?>
</select>年年度统计 <input type="button" onclick="viewYear()" value="查看" />
</div>
<!-- 柱状图(按报修部门统计) -->
<?
$dataArray="";
$nameArray="";
$arrDepartmentIDName = MakeNameValueArray($cfg_mysql_database,$tbl_department,"id","name");
$strQuery = "SELECT * FROM ".$tbl_department." ORDER BY id DESC LIMIT 0,1";
$objDb_Sql1->query($strQuery);
$objDb_Sql1->next_record();
$intMaxDepartmentId = $objDb_Sql1->f("id");
for($intCount = 1; $intCount <= $intMaxDepartmentId; $intCount++)
{
$strQuery = "SELECT COUNT(*) FROM ".$tbl_baoxiu." WHERE request_department_id='".$intCount."' AND add_time>='".$strStartYear."-".$strStartMonth."-01 00:00:00' AND add_time<='".$strEndYear."-".$strEndMonth."-31 23:59:59'";
$objDb_Sql1->query($strQuery);
$objDb_Sql1->next_record();
if($objDb_Sql1->f(0) != 0)
{
$dataArray .= $objDb_Sql1->f(0).",";
$nameArray .= $arrDepartmentIDName[$intCount].",";
}
}
$dataArray = substr($dataArray,0,strlen($dataArray)-1);
$nameArray = substr($nameArray,0,strlen($nameArray)-1);
echo "<script>getdata_and_name1('".$dataArray."','".$nameArray."');</script>";
?>
<!-- 饼状图(按问题类型统计) -->
<?
$dataArray="";
$nameArray="";
$arrTroubleIDName = MakeNameValueArray($cfg_mysql_database,$tbl_trouble,"id","name");
$strQuery = "SELECT * FROM ".$tbl_department." ORDER BY id DESC LIMIT 0,1";
$objDb_Sql1->query($strQuery);
$objDb_Sql1->next_record();
$intMaxTroubleId = $objDb_Sql1->f("id");
for($intCount = 1; $intCount <= $intMaxTroubleId; $intCount++)
{
$strQuery = "SELECT COUNT(*) FROM ".$tbl_baoxiu." WHERE trouble_code like '%".$intCount.",%' AND add_time>='".$strStartYear."-".$strStartMonth."-01 00:00:00' AND add_time<='".$strEndYear."-".$strEndMonth."-31 23:59:59'";
$objDb_Sql1->query($strQuery);
$objDb_Sql1->next_record();
if($objDb_Sql1->f(0) != 0)
{
$dataArray .= $objDb_Sql1->f(0).",";
$nameArray .= $arrTroubleIDName[$intCount].",";
}
}
$strQuery = "SELECT COUNT(*) FROM ".$tbl_baoxiu." WHERE has_other_trouble='1'";
$objDb_Sql1->query($strQuery);
$objDb_Sql1->next_record();
$dataArray .= $objDb_Sql1->f(0).",";
$nameArray .= "其它,";
$dataArray = substr($dataArray,0,strlen($dataArray)-1);
$nameArray = substr($nameArray,0,strlen($nameArray)-1);
echo "<script>getdata_and_name3('".$dataArray."','".$nameArray."');</script>";
?>
<!-- 折线图(按年度统计) -->
<?
$dataArray = "";
$nameArray = "";
for($intCount = 1; $intCount <= 12; $intCount++)
{
$strMonth = $intCount;
if($intCount < 10)
{
$strMonth = "0".$intCount;
}
$strQuery = "SELECT COUNT(*) FROM ".$tbl_baoxiu." WHERE id like '".$strViewYear.$strMonth."%'";
$objDb_Sql1->query($strQuery);
$objDb_Sql1->next_record();
if($objDb_Sql1->f(0) != 0)
{
$dataArray .= $objDb_Sql1->f(0).",";
$nameArray .= $intCount."月,";
}
}
$dataArray =$strViewYear.",".$dataArray;
$dataArray = substr($dataArray,0,strlen($dataArray)-1);
$nameArray = substr($nameArray,0,strlen($nameArray)-1);
$dataArray="2006,12,12,1,5,7,24,40,10,25,45,16,19";
$nameArray="1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月";
echo "<script>getdata_and_name2('".$dataArray."','".$nameArray."');</script>";
?>
<!-- 统计结束 -->
<div style="position:absolute;left:470px;top:1220px;"><a href="index.php"> 返 回 首 页</a></div>
</body>
</html>
- javascript结合php生成统计图(饼形,折线,柱状)
- 根据统计数据生成柱状统计图
- libchart 在php中做统计图(饼状、柱状,线性)
- highchats与php结合生成动态统计图
- VML+Javascript实现的垂直柱状统计图
- VML+Javascript实现的垂直柱状统计图
- 用JAVASCRIPT生成统计图
- perl-制作统计图(折线)
- 自定义View --- 柱状统计图
- Python画柱状统计图
- 统计图折线
- Echarts柱状折线图
- PHP生成折线图
- Web页面中柱状统计图
- Web页面中柱状统计图
- Web页面中柱状统计图
- C# GDI绘制柱状统计图
- 【PyQt 实例17】柱状统计图
- javascript事件列表解说
- Struts2与Struts1.x的深度比较
- Java中ThreadLocal的设计与使用
- div浏览器兼容问题
- Javascript的IE和Firefox兼容性汇编
- javascript结合php生成统计图(饼形,折线,柱状)
- C#struct 和class的不同
- Linux C 函数参考之接口处理篇
- Data Abstraction and Problem solving with Java
- 计算机网络与小不点
- Linux C 函数参考之环境变量篇
- Visual C#2005中的TreeView控件的使用
- XNA系列教程 2D碰撞教程3:转换物体的碰撞检测
- Linux C 函数参考之终端控制篇