calendar-more.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <title>calendar</title>
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <link rel="stylesheet" href="lib/reset.css">
  7. <script src="lib/esl.js"></script>
  8. <script src="lib/config.js"></script>
  9. <script src="lib/jquery.min.js"></script>
  10. </head>
  11. <body>
  12. <style>
  13. html, body, #main {
  14. width: 100%;
  15. height: 100%;
  16. }
  17. </style>
  18. <div id="main"></div>
  19. <script>
  20. var getVirtulData = function(year) {
  21. year = year || '2017';
  22. var datas = [];
  23. var arr31 = [1, 3, 5, 7, 8, 10, 12];
  24. var arr30 = [4, 6, 9, 11];
  25. for (var i = 1; i <= 31; i++) {
  26. for (var j = arr31.length - 1; j >= 0; j--) {
  27. datas.push([year + '-' + arr31[j] + '-' + i, Math.floor(Math.random() * 1000)]);
  28. }
  29. }
  30. for (var i = 1; i <= 30; i++) {
  31. for (var j = arr30.length - 1; j >= 0; j--) {
  32. datas.push([year + '-' + arr30[j] + '-' + i, Math.floor(Math.random() * 1000)]);
  33. }
  34. }
  35. for (var i = 1; i <= 29; i++) {
  36. datas.push([year + '-2-' + i, Math.floor(Math.random() * 1000)]);
  37. }
  38. return datas;
  39. }
  40. var graphData = [
  41. [
  42. 1485878400000,
  43. 260
  44. ],
  45. [
  46. 1486137600000,
  47. 200
  48. ],
  49. [
  50. 1486569600000,
  51. 279
  52. ],
  53. [
  54. 1486915200000,
  55. 847
  56. ],
  57. [
  58. 1487347200000,
  59. 241
  60. ],
  61. [
  62. 1487779200000,
  63. 411
  64. ],
  65. [
  66. 1488124800000,
  67. 985
  68. ]
  69. ];
  70. var links = graphData.map(function (item, idx) {
  71. return {
  72. source: idx,
  73. target: idx + 1
  74. };
  75. });
  76. links.pop();
  77. require([
  78. 'echarts'
  79. // 'echarts/chart/heatmap',
  80. // 'echarts/chart/scatter',
  81. // 'echarts/chart/effectScatter',
  82. // 'echarts/chart/graph',
  83. // 'echarts/component/title',
  84. // 'echarts/component/legend',
  85. // 'echarts/component/calendar',
  86. // 'echarts/component/tooltip',
  87. // 'echarts/component/visualMap'
  88. ], function (echarts) {
  89. var chart = echarts.init(document.getElementById('main'));
  90. chart.setOption({
  91. tooltip: {
  92. position: 'top'
  93. },
  94. visualMap: {
  95. min: 0,
  96. max: 1000,
  97. calculable: true,
  98. orient: 'horizontal',
  99. left: 'center',
  100. top: 650
  101. },
  102. calendar: [
  103. {
  104. orient: 'vertical',
  105. range: '2000-01-01'
  106. },
  107. {
  108. cellSize: 35,
  109. left: 300,
  110. orient: 'vertical',
  111. range: ['2001-02-20', '2001-02-23']
  112. },
  113. {
  114. left: 600,
  115. cellSize: 30,
  116. orient: 'vertical',
  117. range: '2017-02'
  118. },
  119. {
  120. left: 900,
  121. orient: 'vertical',
  122. range: ['2001-02-20', '2001-04-23']
  123. },
  124. {
  125. top: 300,
  126. orient: 'horizontal',
  127. range: ['2001-02-12', '2001-04-23']
  128. },
  129. {
  130. top: 300,
  131. left: 400,
  132. orient: 'horizontal',
  133. range: ['2009-12-20', '2010-04-23']
  134. },
  135. {
  136. top: 300,
  137. left: 820,
  138. orient: 'horizontal',
  139. range: '2010-02-09'
  140. },
  141. {
  142. top: 300,
  143. left: 910,
  144. orient: 'horizontal',
  145. range: ['2010-02-07', '2010-02-11']
  146. },
  147. {
  148. top: 300,
  149. left: 1000,
  150. orient: 'horizontal',
  151. range: ['2010-02-11', '2010-02-13']
  152. },
  153. {
  154. top: 300,
  155. left: 1100,
  156. orient: 'horizontal',
  157. range: ['2010-02-11', '2010-02-14']
  158. },
  159. {
  160. top: 300,
  161. left: 1200,
  162. orient: 'horizontal',
  163. range: ['2010-02-11', '2010-02-16']
  164. },
  165. {
  166. top: 500,
  167. orient: 'horizontal',
  168. range: [2010]
  169. }],
  170. series: [{
  171. type: 'heatmap',
  172. coordinateSystem: 'calendar',
  173. calendarIndex: 0,
  174. data: getVirtulData(2000)
  175. }, {
  176. type: 'heatmap',
  177. coordinateSystem: 'calendar',
  178. calendarIndex: 1,
  179. data: getVirtulData(2001)
  180. }, {
  181. type: 'graph',
  182. coordinateSystem: 'calendar',
  183. calendarIndex: 2,
  184. edgeSymbol: ['none', 'arrow'],
  185. links: links,
  186. symbolSize: 10,
  187. data: graphData
  188. }, {
  189. type: 'scatter',
  190. coordinateSystem: 'calendar',
  191. calendarIndex: 3,
  192. symbolSize: function (val) {
  193. return val[1] / 70;
  194. },
  195. data: getVirtulData(2001)
  196. }, {
  197. type: 'heatmap',
  198. coordinateSystem: 'calendar',
  199. calendarIndex: 4,
  200. data: getVirtulData(2001)
  201. }, {
  202. type: 'heatmap',
  203. coordinateSystem: 'calendar',
  204. calendarIndex: 5,
  205. data: getVirtulData(2010)
  206. }, {
  207. type: 'heatmap',
  208. coordinateSystem: 'calendar',
  209. calendarIndex: 6,
  210. data: getVirtulData(2010)
  211. }, {
  212. type: 'heatmap',
  213. coordinateSystem: 'calendar',
  214. calendarIndex: 7,
  215. data: getVirtulData(2010)
  216. }, {
  217. type: 'heatmap',
  218. coordinateSystem: 'calendar',
  219. calendarIndex: 8,
  220. data: getVirtulData(2010)
  221. }, {
  222. type: 'heatmap',
  223. coordinateSystem: 'calendar',
  224. calendarIndex: 9,
  225. data: getVirtulData(2010)
  226. }, {
  227. type: 'heatmap',
  228. coordinateSystem: 'calendar',
  229. calendarIndex: 10,
  230. data: getVirtulData(2010)
  231. }, {
  232. type: 'heatmap',
  233. coordinateSystem: 'calendar',
  234. calendarIndex: 11,
  235. data: getVirtulData(2010)
  236. }]
  237. });
  238. $(window).resize(function() {
  239. chart.resize();
  240. });
  241. });
  242. </script>
  243. </body>
  244. </html>