项目一

多维度展示数据(参考SaaS车辆生命线的应用)。
image.png

  1. <!DOCTYPE html>
  2. <html style="height: 100%">
  3. <head>
  4. <meta charset="utf-8">
  5. </head>
  6. <body style="height: 100%; margin: 0">
  7. <div id="container" style="height: 100%"></div>
  8. <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
  9. <script type="text/javascript">
  10. var dom = document.getElementById("container");
  11. var myChart = echarts.init(dom);
  12. var app = {};
  13. var option;
  14. var hours = ['12a', '1a', '2a', '3a', '4a', '5a', '6a',
  15. '7a', '8a', '9a', '10a', '11a',
  16. '12p', '1p', '2p', '3p', '4p', '5p',
  17. '6p', '7p', '8p', '9p', '10p', '11p'
  18. ];
  19. var days = ['Saturday', 'Friday', 'Thursday',
  20. 'Wednesday', 'Tuesday', 'Monday', 'Sunday'
  21. ];
  22. var data = [
  23. [0, 0, 5],
  24. [0, 1, 1],
  25. [0, 2, 0],
  26. [0, 3, 0],
  27. [0, 4, 0],
  28. [0, 5, 0],
  29. [0, 6, 0],
  30. [0, 7, 0],
  31. [0, 8, 0],
  32. [0, 9, 0],
  33. [0, 10, 0],
  34. [0, 11, 2],
  35. [0, 12, 4],
  36. [0, 13, 1],
  37. [0, 14, 1],
  38. [0, 15, 3],
  39. [0, 16, 4],
  40. [0, 17, 6],
  41. [0, 18, 4],
  42. [0, 19, 4],
  43. [0, 20, 3],
  44. [0, 21, 3],
  45. [0, 22, 2],
  46. [0, 23, 5],
  47. [1, 0, 7],
  48. [1, 1, 0],
  49. [1, 2, 0],
  50. [1, 3, 0],
  51. [1, 4, 0],
  52. [1, 5, 0],
  53. [1, 6, 0],
  54. [1, 7, 0],
  55. [1, 8, 0],
  56. [1, 9, 0],
  57. [1, 10, 5],
  58. [1, 11, 2],
  59. [1, 12, 2],
  60. [1, 13, 6],
  61. [1, 14, 9],
  62. [1, 15, 11],
  63. [1, 16, 6],
  64. [1, 17, 7],
  65. [1, 18, 8],
  66. [1, 19, 12],
  67. [1, 20, 5],
  68. [1, 21, 5],
  69. [1, 22, 7],
  70. [1, 23, 2],
  71. [2, 0, 1],
  72. [2, 1, 1],
  73. [2, 2, 0],
  74. [2, 3, 0],
  75. [2, 4, 0],
  76. [2, 5, 0],
  77. [2, 6, 0],
  78. [2, 7, 0],
  79. [2, 8, 0],
  80. [2, 9, 0],
  81. [2, 10, 3],
  82. [2, 11, 2],
  83. [2, 12, 1],
  84. [2, 13, 9],
  85. [2, 14, 8],
  86. [2, 15, 10],
  87. [2, 16, 6],
  88. [2, 17, 5],
  89. [2, 18, 5],
  90. [2, 19, 5],
  91. [2, 20, 7],
  92. [2, 21, 4],
  93. [2, 22, 2],
  94. [2, 23, 4],
  95. [3, 0, 7],
  96. [3, 1, 3],
  97. [3, 2, 0],
  98. [3, 3, 0],
  99. [3, 4, 0],
  100. [3, 5, 0],
  101. [3, 6, 0],
  102. [3, 7, 0],
  103. [3, 8, 1],
  104. [3, 9, 0],
  105. [3, 10, 5],
  106. [3, 11, 4],
  107. [3, 12, 7],
  108. [3, 13, 14],
  109. [3, 14, 13],
  110. [3, 15, 12],
  111. [3, 16, 9],
  112. [3, 17, 5],
  113. [3, 18, 5],
  114. [3, 19, 10],
  115. [3, 20, 6],
  116. [3, 21, 4],
  117. [3, 22, 4],
  118. [3, 23, 1],
  119. [4, 0, 1],
  120. [4, 1, 3],
  121. [4, 2, 0],
  122. [4, 3, 0],
  123. [4, 4, 0],
  124. [4, 5, 1],
  125. [4, 6, 0],
  126. [4, 7, 0],
  127. [4, 8, 0],
  128. [4, 9, 2],
  129. [4, 10, 4],
  130. [4, 11, 4],
  131. [4, 12, 2],
  132. [4, 13, 4],
  133. [4, 14, 4],
  134. [4, 15, 14],
  135. [4, 16, 12],
  136. [4, 17, 1],
  137. [4, 18, 8],
  138. [4, 19, 5],
  139. [4, 20, 3],
  140. [4, 21, 7],
  141. [4, 22, 3],
  142. [4, 23, 0],
  143. [5, 0, 2],
  144. [5, 1, 1],
  145. [5, 2, 0],
  146. [5, 3, 3],
  147. [5, 4, 0],
  148. [5, 5, 0],
  149. [5, 6, 0],
  150. [5, 7, 0],
  151. [5, 8, 2],
  152. [5, 9, 0],
  153. [5, 10, 4],
  154. [5, 11, 1],
  155. [5, 12, 5],
  156. [5, 13, 10],
  157. [5, 14, 5],
  158. [5, 15, 7],
  159. [5, 16, 11],
  160. [5, 17, 6],
  161. [5, 18, 0],
  162. [5, 19, 5],
  163. [5, 20, 3],
  164. [5, 21, 4],
  165. [5, 22, 2],
  166. [5, 23, 0],
  167. [6, 0, 1],
  168. [6, 1, 0],
  169. [6, 2, 0],
  170. [6, 3, 0],
  171. [6, 4, 0],
  172. [6, 5, 0],
  173. [6, 6, 0],
  174. [6, 7, 0],
  175. [6, 8, 0],
  176. [6, 9, 0],
  177. [6, 10, 1],
  178. [6, 11, 0],
  179. [6, 12, 2],
  180. [6, 13, 1],
  181. [6, 14, 3],
  182. [6, 15, 4],
  183. [6, 16, 0],
  184. [6, 17, 0],
  185. [6, 18, 0],
  186. [6, 19, 0],
  187. [6, 20, 1],
  188. [6, 21, 2],
  189. [6, 22, 2],
  190. [6, 23, 6]
  191. ];
  192. option = {
  193. tooltip: {
  194. position: 'top'
  195. },
  196. title: [],
  197. singleAxis: [],
  198. series: []
  199. };
  200. days.forEach(function(day, idx) {
  201. option.title.push({
  202. textBaseline: 'middle',
  203. top: (idx + 0.5) * 100 / 7 + '%',
  204. text: day
  205. });
  206. option.singleAxis.push({
  207. left: 150,
  208. type: 'category',
  209. boundaryGap: false,
  210. data: hours,
  211. top: (idx * 100 / 7 + 5) + '%',
  212. height: (100 / 7 - 10) + '%',
  213. axisLabel: {
  214. interval: 2
  215. }
  216. });
  217. option.series.push({
  218. singleAxisIndex: idx,
  219. coordinateSystem: 'singleAxis',
  220. type: 'scatter',
  221. data: [],
  222. symbolSize: function(dataItem) {
  223. return dataItem[1] * 4;
  224. }
  225. });
  226. });
  227. data.forEach(function(dataItem) {
  228. option.series[dataItem[0]].data.push([dataItem[1], dataItem[2]]);
  229. });
  230. if (option && typeof option === 'object') {
  231. myChart.setOption(option);
  232. }
  233. </script>
  234. </body>
  235. </html>