reference.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*function get_data(url, callback){
  2. if(url=="la.anyone.alldata"){
  3. callback([
  4. {name:"张三", id:133, approve:300, decline:400, Accumulate:1000,worktime:1},
  5. {name:"李四", id:133, approve:300, decline:400, Accumulate:1000,worktime:2},
  6. ]);
  7. return;
  8. }
  9. callback([{x:1527957798468,y:3000},{x:1527957799468,y:3000},{x:1527957800468,y:3000.5},{x:1527957801468,y:3001}]);
  10. }
  11. get_data('la.acceptedCount.3600',mmm);
  12. function mmm(shuju) {
  13. console.log("------ getting la.acceptedCount.3000 -------")
  14. console.log(shuju);
  15. var chart = Highcharts.chart('container1',{
  16. chart: {
  17. type: 'spline'
  18. },
  19. title: {
  20. text: '月平均降雨量'
  21. },
  22. subtitle: {
  23. text: '数据来源: WorldClimate.com'
  24. },
  25. xAxis: {
  26. tickInterval: 1000, // 坐标轴刻度间隔为一星期
  27. tickWidth: 0,
  28. gridLineWidth: 1,
  29. // 时间格式化字符
  30. // 默认会根据当前的刻度间隔取对应的值,即当刻度间隔为一周时,取 week 值
  31. dateTimeLabelFormats: {
  32. week: '%Y-%m-%d'
  33. }
  34. },
  35. yAxis: {
  36. // min: 0,
  37. // title: {
  38. // text: '降雨量 (mm)'
  39. // }
  40. },
  41. tooltip: {
  42. // head + 每个 point + footer 拼接成完整的 table
  43. headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
  44. pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
  45. '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
  46. footerFormat: '</table>',
  47. shared: true,
  48. useHTML: true
  49. },
  50. plotOptions: {
  51. column: {
  52. borderWidth: 0
  53. }
  54. },
  55. series: [{
  56. name: '东京',
  57. data: shuju
  58. }]
  59. });
  60. }
  61. setInterval(lll,100);
  62. function lll() {
  63. }
  64. get_data("la.anyone.alldata", showAllData);
  65. function showAllData(shuju){
  66. var htmlbody = "";
  67. var i = 0;
  68. for(i=0; i < shuju.length; i++){
  69. var one_person = shuju[i];
  70. htmlbody += "<tr>";
  71. htmlbody += " <tr>\n" +
  72. " <td>"+one_person.name+"("+one_person.id+")</td>\n" +
  73. " <td>"+one_person.approve+"</td>\n" +
  74. " <td>"+one_person.decline+"</td>\n" +
  75. " </tr>";
  76. htmlbody += "</tr>";
  77. }
  78. $("#rank-one").html(htmlbody);
  79. }*/
  80. var chart = Highcharts.chart('container1', {
  81. title: {
  82. text: '合格数'
  83. },
  84. /*subtitle: {
  85. text: '数据来源:thesolarfoundation.com'
  86. },*/
  87. xAxis: {
  88. title: {
  89. text: '员工'
  90. }
  91. },
  92. yAxis: {
  93. title: {
  94. text: '就业人数'
  95. }
  96. },
  97. legend: {
  98. layout: 'vertical',
  99. align: 'right',
  100. verticalAlign: 'middle'
  101. },
  102. plotOptions: {
  103. series: {
  104. label: {
  105. connectorAllowed: false
  106. },
  107. pointStart: 2010
  108. }
  109. },
  110. series: [{
  111. name: '安装,实施人员',
  112. data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
  113. }, {
  114. name: '工人',
  115. data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
  116. }, {
  117. name: '销售',
  118. data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]
  119. }, {
  120. name: '项目开发',
  121. data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227]
  122. }, {
  123. name: '其他',
  124. data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
  125. }],
  126. responsive: {
  127. rules: [{
  128. condition: {
  129. maxWidth: 500
  130. },
  131. chartOptions: {
  132. legend: {
  133. layout: 'horizontal',
  134. align: 'center',
  135. verticalAlign: 'bottom'
  136. }
  137. }
  138. }]
  139. }
  140. });
  141. var chart = Highcharts.chart('container2', {
  142. chart: {
  143. type: 'bar'
  144. },
  145. title: {
  146. text: '不合格数'
  147. },
  148. xAxis: {
  149. categories: ['苹果', '橘子', '梨', '葡萄', '香蕉']
  150. },
  151. yAxis: {
  152. min: 0,
  153. title: {
  154. text: '员工'
  155. }
  156. },
  157. legend: {
  158. /* 图例显示顺序反转
  159. * 这是因为堆叠的顺序默认是反转的,可以设置
  160. * yAxis.reversedStacks = false 来达到类似的效果
  161. */
  162. reversed: true
  163. },
  164. plotOptions: {
  165. series: {
  166. stacking: 'normal'
  167. }
  168. },
  169. series: [{
  170. name: '小张',
  171. data: [5, 3, 4, 7, 2]
  172. }, {
  173. name: '小彭',
  174. data: [2, 2, 3, 2, 1]
  175. }, {
  176. name: '小潘',
  177. data: [3, 4, 4, 2, 5]
  178. }]
  179. });
  180. var chart = Highcharts.chart('container3', {
  181. chart: {
  182. type: 'column'
  183. },
  184. title: {
  185. text: '堆积数'
  186. },
  187. /*subtitle: {
  188. text: '数据截止 2017-03,来源: <a href="https://en.wikipedia.org/wiki/List_of_cities_proper_by_population">Wikipedia</a>'
  189. },*/
  190. xAxis: {
  191. type: 'category',
  192. /* labels: {
  193. rotation: -45 // 设置轴标签旋转角度
  194. }*/
  195. title: {
  196. text: '员工'
  197. }
  198. },
  199. yAxis: {
  200. min: 0,
  201. title: {
  202. text: '人口 (百万)'
  203. }
  204. },
  205. legend: {
  206. enabled: false
  207. },
  208. tooltip: {
  209. pointFormat: '人口总量: <b>{point.y:.1f} 百万</b>'
  210. },
  211. series: [{
  212. name: '总人口',
  213. data: [
  214. ['上海', 24.25],
  215. ['卡拉奇', 23.50],
  216. ['北京', 21.51],
  217. ['德里', 16.78],
  218. ['拉各斯', 16.06],
  219. ['天津', 15.20],
  220. ['伊斯坦布尔', 14.16],
  221. ['东京', 13.51],
  222. ['广州', 13.08],
  223. ['孟买', 12.44],
  224. ['莫斯科', 12.19],
  225. ['圣保罗', 12.03],
  226. ['深圳', 10.46],
  227. ['雅加达', 10.07],
  228. ['拉合尔', 10.05],
  229. ['首尔', 9.99],
  230. ['武汉', 9.78],
  231. ['金沙萨', 9.73],
  232. ['开罗', 9.27],
  233. ['墨西哥', 8.87]
  234. ],
  235. dataLabels: {
  236. enabled: true,
  237. rotation: -90,
  238. color: '#FFFFFF',
  239. align: 'right',
  240. format: '{point.y:.1f}', // :.1f 为保留 1 位小数
  241. y: 10
  242. }
  243. }]
  244. });
  245. var chart = Highcharts.chart('container4', {
  246. chart: {
  247. type: 'line'
  248. },
  249. title: {
  250. text: '工作时长'
  251. },
  252. /*subtitle: {
  253. text: '数据来源: WorldClimate.com'
  254. },*/
  255. xAxis: {
  256. title: {
  257. text: '员工'
  258. }
  259. },
  260. yAxis: {
  261. title: {
  262. text: '气温 (°C)'
  263. }
  264. },
  265. plotOptions: {
  266. line: {
  267. dataLabels: {
  268. // 开启数据标签
  269. enabled: true
  270. },
  271. // 关闭鼠标跟踪,对应的提示框、点击事件会失效
  272. enableMouseTracking: false
  273. }
  274. },
  275. series: [{
  276. name: '东京',
  277. data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
  278. }, {
  279. name: '伦敦',
  280. data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
  281. }]
  282. });
  283. var chart = Highcharts.chart('container5', {
  284. chart: {
  285. type: 'column'
  286. },
  287. title: {
  288. text: '不良率'
  289. },
  290. xAxis: {
  291. /*categories: ['苹果', '橘子', '梨', '葡萄', '香蕉']*/
  292. title: {
  293. text: '员工'
  294. }
  295. },
  296. yAxis: {
  297. min: 0,
  298. title: {
  299. text: '水果消费总量'
  300. }
  301. },
  302. tooltip: {
  303. pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b>' +
  304. '({point.percentage:.0f}%)<br/>',
  305. //:.0f 表示保留 0 位小数,详见教程:https://www.hcharts.cn/docs/basic-labels-string-formatting
  306. shared: true
  307. },
  308. plotOptions: {
  309. column: {
  310. stacking: 'percent'
  311. }
  312. },
  313. series: [{
  314. name: '小张',
  315. data: [5, 3, 4, 7, 2]
  316. }, {
  317. name: '小彭',
  318. data: [2, 2, 3, 2, 1]
  319. }, {
  320. name: '小潘',
  321. data: [3, 4, 4, 2, 5]
  322. }]
  323. });