0

0

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

php中文网

php中文网

发布时间:2016-07-25 08:55:28

|

1302人浏览过

|

来源于php中文网

原创

  1. <script language="javascript" type="text/javascript"></script>

  2. <script language="javascript"></script>
  3. function getdata_and_name2(data,name){
  4. var dataArray2 = new Array()
  5. var dataArray =data.split(",");
  6. var nameArray =name.split(",");
  7. dataArray2[0]="#0000FF,1,2,3,"+dataArray[0];
  8. for(var i=1;i
  9. dataArray2[i]=dataArray[i]*10;
  10. }
  11. var total =new Array(nameArray,dataArray2);
  12. table2(total,70,980,804,200,1);
  13. }
  14. function table2(total,table_x,table_y,all_width,all_height,line_no)
  15. {
  16. //参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,折线条数)
  17. //***************************************************************************************
  18. var line_color = "#69f";
  19. var left_width = 70;
  20. var total_no = total[1].length
  21. var temp1,temp2,temp3
  22. temp1 = 0;
  23. for(var i=1;i
  24. {
  25. for(var j=1;j
  26. {
  27. if(temp1
  28. temp1 = total[j][i];
  29. }
  30. }
  31. temp1 = parseInt(temp1);
  32. if(temp1>9)
  33. {
  34. temp2 = temp1.toString().substr(1,1);
  35. if(temp2>4)
  36. {
  37. temp3 = (parseInt(temp1/(Math.pow(10,(temp1.toString().length-1))))+1)*Math.pow(10,(temp1.toString().length-1));
  38. }
  39. else
  40. {
  41. temp3 = (praseInt(temp1/(Math.pow(10,(temp1.toString().length-1))))+0.5)*Math.pow(10,(temp1.toString().length-1))
  42. }
  43. }
  44. else
  45. {
  46. if(temp1>4)
  47. {
  48. emp3 = 10;
  49. }
  50. else
  51. {
  52. temp3 = 5;
  53. }
  54. }
  55. temp4 = temp3;
  56. document.write("");
  57. for(var i=0;i
  58. {
  59. document.write("");
  60. document.write("");
  61. document.write("");
  62. document.write("
    " + temp4 + "
    ");
  63. temp4 = temp4 - temp3/5;
  64. }
  65. document.write("");
  66. document.write("");
  67. var tmpStr = ""
  68. for(i=1;i
  69. {
  70. var re = /,/g;
  71. tmpStr += ",[\"" + total[i][0].replace(re,"\",\"") + "\"]"
  72. }
  73. tmpStr = tmpStr.substr(1,tmpStr.length-1)
  74. var line_code = eval("new Array(" + tmpStr + ")")
  75. for(var j=1;j
  76. {
  77. for(var i=1;i
  78. {
  79. var x1 = table_x + left_width + all_width * (i - 1)/(total_no-1)
  80. var y1 = table_y + (temp3 - total[j][i]) * (all_height/temp3)
  81. var x2 = table_x + left_width + all_width * i/(total_no-1)
  82. var y2 = table_y + (temp3 - total[j][i+1]) * (all_height/temp3)
  83. document.write("");
  84. switch (parseInt(line_code[j-1][2]))
  85. {
  86. case 1:
  87. break;
  88. case 2:
  89. document.write("");
  90. break;
  91. case 3:
  92. document.write("");
  93. break;
  94. case 4:
  95. document.write("");
  96. break;
  97. case 5:
  98. document.write("");
  99. break;
  100. case 6:
  101. document.write("");
  102. break;
  103. case 7:
  104. document.write("");
  105. break;
  106. }
  107. document.write("");
  108. switch (parseInt(line_code[j-1][3]))
  109. {
  110. case 1:
  111. break;
  112. case 2:
  113. document.write("");
  114. break;
  115. case 3:
  116. document.write("");
  117. break;
  118. }
  119. }
  120. switch (parseInt(line_code[j-1][3]))
  121. {
  122. case 1:
  123. break;
  124. case 2:
  125. document.write("");
  126. break;
  127. case 3:
  128. document.write("");
  129. break;
  130. }
  131. }
  132. for(var i=0;i
  133. {
  134. document.write("");
  135. document.write("");
  136. document.write("
    " + total[0][i] + "
    ");
  137. }
  138. var tb_height = 30
  139. document.write("");
  140. for(var i=0;i
  141. {
  142. document.write("");
  143. document.write("
    " + line_code[i][4] + "
    ");
  144. document.write("");
  145. }
  146. }
  147. <script language="javascript"></script>
  148. function getdata_and_name1(data,name){
  149. var dataArray =data.split(",");
  150. var nameArray =name.split(",");
  151. var total =new Array(dataArray,nameArray);
  152. table1(total,70,350,20,30,800,100,"A");
  153. }
  154. function table1(total,table_x,table_y,thickness,table_width,all_width,all_height,table_type){
  155. //参数含义(传递的数组,横坐标,纵坐标,柱子的厚度,柱子的宽度,图表的宽度,图表的高度,图表的类型)
  156. //纯ASP代码生成图表函数1——柱状图
  157. //***************************************************************************************
  158. var tmdColor1 = new Array();
  159. tmdColor1[0] = "#d1ffd1";
  160. tmdColor1[1] = "#ffbbbb";
  161. tmdColor1[2] = "#ffe3bb";
  162. tmdColor1[3] = "#cff4f3";
  163. tmdColor1[4] = "#d9d9e5";
  164. tmdColor1[5] = "#ffc7ab";
  165. tmdColor1[6] = "#ecffb7";
  166. tmdColor1[7] = "#97bd00";
  167. tmdColor1[8] = "#009900";
  168. tmdColor1[9] = "#cc3300";
  169. tmdColor1[10] = "#ffcc00";
  170. tmdColor1[11] = "#3366cc";
  171. tmdColor1[12] = "#33cc33";
  172. tmdColor1[13] = "#ff9933";
  173. tmdColor1[14] = "#cccc99";
  174. tmdColor1[15] = "#99cc66";
  175. tmdColor1[16] = "#66ff99";
  176. tmdColor1[17] = "#4f6600";
  177. tmdColor1[18] = "#481000";
  178. tmdColor1[19] = "#7d6400";
  179. tmdColor1[20] = "#173064";
  180. tmdColor1[21] = "#173064";
  181. tmdColor1[22] = "#1a6a1a";
  182. tmdColor1[23] = "#974b00";
  183. tmdColor1[24] = "#78793c";
  184. tmdColor1[25] = "#557e27";
  185. tmdColor1[26] = "#009337";
  186. var tmdColor2 = new Array();
  187. tmdColor2[0] = "#00ff00";
  188. tmdColor2[1] = "#ff0000";
  189. tmdColor2[2] = "#ff9900";
  190. tmdColor2[3] = "#33cccc";
  191. tmdColor2[4] = "#666699";
  192. tmdColor2[5] = "#993300";
  193. tmdColor2[6] = "#99cc00";
  194. tmdColor2[7] = "#97bd00";
  195. tmdColor2[8] = "#009900";
  196. tmdColor2[9] = "#cc3300";
  197. tmdColor2[10] = "#ffcc00";
  198. tmdColor2[11] = "#3366cc";
  199. tmdColor2[12] = "#33cc33";
  200. tmdColor2[13] = "#ff9933";
  201. tmdColor2[14] = "#cccc99";
  202. tmdColor2[15] = "#99cc66";
  203. tmdColor2[16] = "#66ff99";
  204. tmdColor2[17] = "#4f6600";
  205. tmdColor2[18] = "#481000";
  206. tmdColor2[19] = "#7d6400";
  207. tmdColor2[20] = "#173064";
  208. tmdColor2[21] = "#173064";
  209. tmdColor2[22] = "#1a6a1a";
  210. tmdColor2[23] = "#974b00";
  211. tmdColor2[24] = "#78793c";
  212. tmdColor2[25] = "#557e27";
  213. tmdColor2[26] = "#009337";
  214. var tb_color = new Array(tmdColor1,tmdColor2);
  215. var line_color = "#69f";
  216. var left_width = 70;
  217. var length = thickness/2;
  218. var total_no = total[0].length;
  219. var temp1 = 0;
  220. var temp2,temp4,temp4;
  221. for(var i = 0;i
  222. {
  223. if(temp1
  224. {
  225. temp1 = total[0][i];
  226. }
  227. }
  228. temp1 = parseInt(temp1.toString());
  229. if(temp1>9)
  230. {
  231. temp2 = temp1.toString().substr(1,1)
  232. if(temp2>4)
  233. {
  234. temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
  235. }
  236. else
  237. {
  238. temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
  239. }
  240. }
  241. else
  242. {
  243. if(temp1>4)
  244. temp3 = 10;
  245. else
  246. temp3 = 5;
  247. }
  248. temp4=temp3
  249. document.write("");
  250. document.write("");
  251. document.write("");
  252. switch (table_type)
  253. {
  254. case "A":
  255. var table_space = (all_width-table_width*total_no)/total_no;
  256. document.write("");
  257. for(var i=0;i
  258. {
  259. document.write("");
  260. document.write("");
  261. document.write("");
  262. document.write("");
  263. temp4 = temp4-temp3/5;
  264. }
  265. for(var i=0;i
  266. {
  267. var temp_space = table_x + left_width + table_space / 2 + table_space * i + table_width * i;
  268. document.write("");
  269. document.write("")
  270. document.write("");
  271. document.write("");
  272. document.write("");
  273. document.write("
    " + total[0][i] + "
    ");
  274. document.write("");
  275. document.write("
    " + total[1][i] + "
    ");
  276. }
  277. break;
  278. case "B":
  279. var table_space = (all_height - table_width * total_no) / total_no;
  280. document.write("");
  281. for(var i=0;i
  282. {
  283. document.write("");
  284. document.write("");
  285. document.write("");
  286. document.write("");
  287. temp4 = temp4 - temp3 / 5;
  288. }
  289. for(var i=0;i
  290. {
  291. var temp_space = table_space/2 + table_space * i + table_width * i;
  292. document.write("");
  293. document.write("");
  294. document.write("");
  295. document.write("");
  296. document.write("");
  297. document.write("
    " + total[0][i] + "
    ");
  298. document.write("");
  299. document.write("
    " + total[1][i] + "
    ");
  300. }
  301. }
  302. }
  303. <script language="JavaScript" type="text/JavaScript"></script>

相关文章

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法

本专题系统整理pixiv网页版官网入口及登录访问方式,涵盖官网登录页面直达路径、在线阅读入口及快速进入方法说明,帮助用户高效找到pixiv官方网站,实现便捷、安全的网页端浏览与账号登录体验。

705

2026.02.13

微博网页版主页入口与登录指南_官方网页端快速访问方法
微博网页版主页入口与登录指南_官方网页端快速访问方法

本专题系统整理微博网页版官方入口及网页端登录方式,涵盖首页直达地址、账号登录流程与常见访问问题说明,帮助用户快速找到微博官网主页,实现便捷、安全的网页端登录与内容浏览体验。

233

2026.02.13

Flutter跨平台开发与状态管理实战
Flutter跨平台开发与状态管理实战

本专题围绕Flutter框架展开,系统讲解跨平台UI构建原理与状态管理方案。内容涵盖Widget生命周期、路由管理、Provider与Bloc状态管理模式、网络请求封装及性能优化技巧。通过实战项目演示,帮助开发者构建流畅、可维护的跨平台移动应用。

117

2026.02.13

TypeScript工程化开发与Vite构建优化实践
TypeScript工程化开发与Vite构建优化实践

本专题面向前端开发者,深入讲解 TypeScript 类型系统与大型项目结构设计方法,并结合 Vite 构建工具优化前端工程化流程。内容包括模块化设计、类型声明管理、代码分割、热更新原理以及构建性能调优。通过完整项目示例,帮助开发者提升代码可维护性与开发效率。

22

2026.02.13

Redis高可用架构与分布式缓存实战
Redis高可用架构与分布式缓存实战

本专题围绕 Redis 在高并发系统中的应用展开,系统讲解主从复制、哨兵机制、Cluster 集群模式及数据分片原理。内容涵盖缓存穿透与雪崩解决方案、分布式锁实现、热点数据优化及持久化策略。通过真实业务场景演示,帮助开发者构建高可用、可扩展的分布式缓存系统。

61

2026.02.13

c语言 数据类型
c语言 数据类型

本专题整合了c语言数据类型相关内容,阅读专题下面的文章了解更多详细内容。

30

2026.02.12

雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法
雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法

本专题系统整理雨课堂网页版官方入口及在线登录方式,涵盖账号登录流程、官方直连入口及平台访问方法说明,帮助师生用户快速进入雨课堂在线教学平台,实现便捷、高效的课程学习与教学管理体验。

15

2026.02.12

豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法
豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法

本专题汇总豆包AI官方网页版入口及在线使用方式,涵盖智能写作工具、图片生成体验入口和官网登录方法,帮助用户快速直达豆包AI平台,高效完成文本创作与AI生图任务,实现便捷智能创作体验。

669

2026.02.12

PostgreSQL性能优化与索引调优实战
PostgreSQL性能优化与索引调优实战

本专题面向后端开发与数据库工程师,深入讲解 PostgreSQL 查询优化原理与索引机制。内容包括执行计划分析、常见索引类型对比、慢查询优化策略、事务隔离级别以及高并发场景下的性能调优技巧。通过实战案例解析,帮助开发者提升数据库响应速度与系统稳定性。

58

2026.02.12

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号