首頁 >後端開發 >php教程 >php折線圖、餅狀圖、長條圖的生成實例

php折線圖、餅狀圖、長條圖的生成實例

WBOY
WBOY原創
2016-07-25 08:55:281010瀏覽
  1. var tb_color = new Array(tmdColor1,tmdColor2);

  2. var tb_height = tmdColor1,tmdColor2);
  3. var tb_height = tmdColor1,tmdColor2);
  4. var tb_height = tmdColor1,tmdColor2);
  5. var tb_height = tmdColor1,tmdColor2);
  6. var tb_height = tmdColor1,tmdColor2);
  7. var tb_height = 230;
  8. var total_no = total[0].length;
  9. var totalpie = 0;
  10. for(var i=0;i{total[1][i ]*=100;totalpie += total[1][i];}var PreAngle = 0;for(var i=0;i { document.write("");PreAngle += total[1][i] / totalpie; }
  11. if(table_type=="A")
  12. {
  13. document.write("");
  14. for(var i=0;i{
  15. document.write("");
  16. document.write("" + 總計[0][i] + " ;
    v:shape>");
  17. document.write(" ");
  18. / / 顯示比例數
  19. document.write("");
  20. document. write("" + Math.round(parseFloat(total[1][i ]*100/totalpie)*100)/100 + "%
  21. ");
  22. }
  23. }
  24. if(table_type == "B")
  25. {
  26. var pie = 3.14159265358979;
  27. var Tempfor(var i=0;i{
  28. var TempAngle = 餅* 2 * (total[1][i] / (totalpie * 2) + TempPie);
  29. var x1 = table_x + all_width/2 + Math.cos( TempAngle) * all_width * 3/8;
  30. var y1 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/8;
  31. var x2 = table_x + all_width/2 + Math.cos( TempAngle) * all_width * 3/4;
  32. var y2 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/4;
  33. if(x2>table_x + all_width/2)
  34. {
  35. x3 = x2 + 20;
  36. x4 = x3;
  37. }
  38. else
  39. {
  40. x3 = x2 - 200 ;
  41. x4 = x3 - 100;
  42. }
  43. document.write("");
  44. document.write(" ");
  45. document.write("");
  46. document.write("");
  47. document. write("
" + 總計[0][ i] + " " + Math.round(parseFloat(total[1][i] * 100/totalpie)*100)/100 + "% td>
v:textbox>")
  • TempPie += Total[1][i]/totalpie;
  • }
  • }
  • }
  • //-->
  • 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 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)
  • {
  • //參數意義(傳遞的數組,橫座標,縱座標,圖表的寬度,圖表的高度,折線條數)
  • //******************************************* ********************************************
  • 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{
  • for(var j=1;j{
  • if(temp1 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;
  • else
  • {
  • temp3 = 5;
  • ^}
  • }
  • temp4 = temp3;
  • document.write("");
  • for(var i=0;i{
  • document.write("");
  • document.write("") ;
  • document.write("");
  • document.write("
    " + temp4 + "
  • ");
  • temp4 = temp4 - temp3/5;
  • }
  • document.write("");
  • document.write("") ;
  • var tmpStr = ""
  • for(i=1;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{
  • for(var i=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(" ");
  • switch (parseInt(line_code[j-1][2]))
  • {
  • 情況1:
  • 中斷;
  • 情況2:
  • document.write( " ");
  • break;
  • 情況3:
  • document.write("" );
  • 中斷;
  • 案例4:
  • document.write("");
  • 中斷;
  • 案例5:
  • document.write( "");
  • break;
  • 案例6:
  • document.write("");
  • 中斷;
  • 案例7:
  • document.write("");
  • 中斷;
  • }
  • document.write(" v:line>");
  • switch (parseInt(line_code[j-1][3]))
  • {
  • 情況1:
  • Break;
  • 情況2:
  • document .write("");
  • 中斷;
  • 案例3:
  • document.write("");
  • 中斷;
  • }
  • }
  • switch (parseInt(line_code[j-1][3]))
  • {
  • 情況1:
  • 中斷;
  • 情況2:
  • document.write("");
  • break;
  • 情況3:
  • document.write("");
  • break;
  • }
  • }
  • for(var i=0;i{
  • document.write("");
  • document.write("");
  • document.write("" + Total[0][i] + "");
  • }
  • var tb_height = 30
  • document.write("");
  • for(var i=0;i{
  • document.write("");
  • document.write("
  • " + line_code[i][4] + "
  • ");
  • document.write("均勻>");
  • }
  • }
  • script>
  • 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——柱圖
  • //********** ** ** ********************************************** **** ****** **************************
  • var tmdColor1 = new Array();
  • tmdColor1[0] = "#d1ffd1" ;
  • tmdColor1[1] = "#ffbbbb";
  • tmdColor1[2] = "#ffe3bb";
  • tmdColor1[3] = "#cff4f3";
  • tmdColor1[3] = "#cff4f3";
  • tmdColor1[ 4] = "# d9d9e5";
  • tmdColor1[5] = "#ffc7ab";
  • tmdColor1[6] = "#ecffb7";
  • tmdor1[7] = "#97bbd" ;
  • tmdColor1[8] = "#009900";
  • tmdColor1[9] = "#cc3300";
  • tmdColor1[10] = "#ffcc00";
  • tmdColtmdColor1[10] = "#ffcc00";
  • tmdColtmor1[11] = " 3366cc";
  • tmdColor1[12] = "#33cc33";
  • tmdColor1[13] = "#ff9933";
  • tmdColor1[14] = "#cc99";tmdColor1 [16] = "#66ff99";
  • tmdColor1[17] = "#4f6600";
  • tmdColor1[18] = "#481000";
  • tmdColor1[18] = "#481000"; ] = "# 7d6400";
  • tmdColor1[20] = "#173064";
  • tmdColor1[21] = "#173064";
  • tmdColor1[22] = "#173064";
  • tmdColor1[22] = "#1a6a1a";
  • tmdColor1[22] = "#1a6a1a」; [23] = “#974b00”;
  • tmdColor1[24] = "#78793c";
  • tmdColor1[25] = "#557e27";
  • tmdColor1[26] = "#009337";
  • tmdColor1[26] = "#009337";
  • var tmdor2 = new Ar
  • tmdColor2[0] = "#00ff00";
  • tmdColor2[1] = "#ff0000";
  • tmdColor2[2] = "#ff9900";tmdorColcc2[3] = "#333cc ";
  • tmdColor2[4] = "#666699";
  • tmdColor2[5] = "#993300";
  • tmdColor2[6] = "#99cc00";
  • dtmdColor2[6] = "#99cc00";
  • dtmdor2[7] =f #97bd00";
  • tmdColor2[8] = "#009900";
  • tmdColor2[9] = "#cc3300";
  • tmdColor2[10] = "#ffcc00"; = "#3366cc";
  • tmdColor2[12] = "#33cc33";
  • tmdColor2[13] = "#ff9933";
  • tmdColor2[14] = "#cc99";tmdColor2[16] = "#66ff99";
  • tmdColor2[17] = "#4f6600";
  • tmdColor2[18] = "#4f6600";
  • tmdColor2[18] = "#481000"; tmdColor2[19] = "#7d6400";
  • tmdColor2[20] = "#173064";
  • tmdColor2[21] = "#173064";
  • tmdColor2[21] = "#173064";
  • tmdColor2[22] = "#17366a; 🎜>tmdColor2[23] = "#974b00";
  • tmdColor2[24] = "#78793c";
  • tmdColor2[25] = "#557e27";
  • tmdColor2[25] = "#557e27";
  • tmdColor2[25] = "#557e27";
  • tmdColor2[25] =Col#209333370 ;
  • var tb_color = new Array(tmdColor1,tmdColor2);
  • var line_color = "#69f";
  • var left_width = 70;
  • var length = 厚度/2;
  • var Total_no總共[0].length;
  • var temp1 = 0;
  • var temp2,temp4,temp4;
  • for(var i = 0;i{
  • if( temp1{
  • 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("");
  • document.write("");
  • document.write ( "");
  • 開關(table_type)
  • {
  • case "A":
  • var table_space = (all_width-table_width*total_no)/total_no ;
  • document.write("");
  • for(var i=0 ; i{
  • document.write( "");
  • document.write( "");
  • document.write("");
  • document.write( "");
  • document.write("");
  • document.write (" " + temp4 + "
  • " );
  • temp4 = temp4-temp3/5;
  • }
  • for(var i=0;i{
  • var temp_space = table_x + left_width + table_space / 2 + table_space * i + table_width * i;
  • document.write("; " );
  • document.write("")
  • document .write( "" );
  • document.write("
  • ");
  • document.write("");
  • document.write("" + 總計[0][i] + "
  • ");
  • document.write("");
  • document.write("" + 總計[1][ i] + "
  • ");
  • }
  • break;
  • case " B":
  • var table_space = (all_height - table_width * Total_no) / Total_no;
  • document.write( "");
  • for(var i=0;i {
  • document.write("");
  • document.write("");
  • 文件。text-align :left;top:0 ;翻轉: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'/>");
  • document. write(" ");
  • temp4 = temp4 - temp3 / 5;
  • }
  • for(var i=0;i{
  • var temp_space = table_space/2 + table_space * i + table_width * i;
  • document.write("");
  • document.write("");
  • document.write("");
  • document.write(" v:rect>");
  • document.write("");
  • document.write("" + 總計[0][i] + " tr>
  • " );
  • document.write("");
  • document.write("" + 總計[1][i] + "
  • ");
  • }
  • }
  • }

  • 陳述:
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn