php折线图、饼状图、柱状图的生成实例

WBOY
发布: 2016-07-25 08:55:28
原创
963 人浏览过
  1. var tb_color = new Array(tmdColor1,tmdColor2);

  2. var tb_height = 30;
  3. var total_no = total[0].length;
  4. var totalpie = 0;
  5. for(var i=0;i{
  6. total[1][i]*=100;
  7. totalpie += total[1][i];
  8. }
  9. var PreAngle = 0;
  10. for(var i=0;i{
  11. document.write("");
  12. PreAngle += total[1][i] / totalpie;
  13. }
  14. if(table_type=="A")
  15. {
  16. document.write("");
  17. for(var i=0;i{
  18. document.write("");
  19. document.write("
    " + total[0][i] + "
  20. ");
  21. document.write("");
  22. //显示比例数
  23. document.write("");
  24. document.write("
    " + Math.round(parseFloat(total[1][i]*100/totalpie)*100)/100 + "%
  25. ");
  26. }
  27. }
  28. if(table_type == "B")
  29. {
  30. var pie = 3.14159265358979;
  31. var TempPie = 0;
  32. for(var i=0;i{
  33. var TempAngle = pie * 2 * (total[1][i] / (totalpie * 2) + TempPie);
  34. var x1 = table_x + all_width/2 + Math.cos(TempAngle) * all_width * 3/8;
  35. var y1 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/8;
  36. var x2 = table_x + all_width/2 + Math.cos(TempAngle) * all_width * 3/4;
  37. var y2 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/4;
  38. if(x2>table_x + all_width/2)
  39. {
  40. x3 = x2 + 20;
  41. x4 = x3;
  42. }
  43. else
  44. {
  45. x3 = x2 - 20;
  46. x4 = x3 - 100;
  47. }
  48. document.write("");
  49. document.write("");
  50. document.write("");
  51. document.write("");
  52. document.write("
    " + total[0][i] + " " + Math.round(parseFloat(total[1][i] * 100/ totalpie)*100)/100 + "%
  53. ")
  54. TempPie += total[1][i]/totalpie;
  55. }
  56. }
  57. }
  58. //-->
");
  • 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]))
  • {
  • case 1:
  • break;
  • case 2:
  • document.write("");
  • break;
  • case 3:
  • document.write("");
  • break;
  • case 4:
  • document.write("");
  • break;
  • case 5:
  • document.write("");
  • break;
  • case 6:
  • document.write("");
  • break;
  • case 7:
  • document.write("");
  • break;
  • }
  • document.write("
  • ");
  • switch (parseInt(line_code[j-1][3]))
  • {
  • case 1:
  • break;
  • case 2:
  • document.write("");
  • break;
  • case 3:
  • document.write("");
  • break;
  • }
  • }
  • switch (parseInt(line_code[j-1][3]))
  • {
  • case 1:
  • break;
  • case 2:
  • document.write("");
  • break;
  • case 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("");
  • }
  • }

  • 来源:php.cn
    本站声明
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
    热门教程
    更多>
    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板
    关于我们 免责声明 Sitemap
    PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!