calendar-month.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. require([
  41. 'echarts'
  42. // 'echarts/chart/heatmap',
  43. // 'echarts/chart/scatter',
  44. // 'echarts/component/title',
  45. // 'echarts/component/legend',
  46. // 'echarts/component/calendar',
  47. // 'echarts/component/tooltip',
  48. // 'echarts/component/visualMap'
  49. ], function (echarts) {
  50. var chart = echarts.init(document.getElementById('main'));
  51. chart.setOption({
  52. tooltip: {
  53. position: 'top'
  54. },
  55. visualMap: {
  56. min: 0,
  57. max: 1000,
  58. calculable: true,
  59. orient: 'horizontal',
  60. left: 'center',
  61. top: 'top'
  62. },
  63. calendar: [
  64. {
  65. monthLabel: {
  66. formatter: '{yy}-{MM}',
  67. position: 'start'
  68. },
  69. range: '2017-01'
  70. },
  71. {
  72. monthLabel: {
  73. formatter: '{yyyy}-{M}',
  74. position: 'end'
  75. },
  76. left: 300,
  77. range: '2017-02'
  78. },
  79. {
  80. monthLabel: {
  81. position: 'start',
  82. posAlign: 'left'
  83. },
  84. left: 550,
  85. range: '2017-03'
  86. },
  87. {
  88. monthLabel: {
  89. position: 'end',
  90. posAlign: 'left'
  91. },
  92. left: 750,
  93. range: '2017-04'
  94. },
  95. {
  96. left: 1000,
  97. monthLabel: {
  98. nameMap: 'cn'
  99. },
  100. range: ['2017-12-01', '2018-01-31']
  101. },
  102. {
  103. monthLabel: {
  104. position: 'start'
  105. },
  106. top: 320,
  107. orient: 'vertical',
  108. range: '2017-01'
  109. },
  110. {
  111. monthLabel: {
  112. position: 'end'
  113. },
  114. top: 320,
  115. left: 300,
  116. orient: 'vertical',
  117. range: '2017-02'
  118. },
  119. {
  120. monthLabel: {
  121. position: 'start',
  122. posAlign: 'left'
  123. },
  124. top: 320,
  125. orient: 'vertical',
  126. left: 550,
  127. range: '2017-03'
  128. },
  129. {
  130. monthLabel: {
  131. position: 'end',
  132. posAlign: 'left'
  133. },
  134. top: 320,
  135. orient: 'vertical',
  136. left: 750,
  137. range: '2017-04'
  138. },
  139. {
  140. monthLabel: {
  141. margin: 20,
  142. formatter: '{yy}-{nameMap}',
  143. textStyle: {
  144. color: '#009688',
  145. fontStyle: 'italic',
  146. fontFamily: 'sans-serif',
  147. fontWeight: 'bolder',
  148. fontSize: 20
  149. }
  150. },
  151. top: 320,
  152. orient: 'vertical',
  153. left: 1000,
  154. range: ['2017-12-01', '2018-01-31']
  155. },
  156. {
  157. monthLabel: {
  158. nameMap: [
  159. 'Jan', '二月', 'Mar',
  160. '四月', '五月', '六月',
  161. '七月', '', '九月',
  162. '十月', '十一月', '十二月'
  163. ]
  164. },
  165. top: 550,
  166. range: '2017'
  167. }],
  168. series: [{
  169. type: 'heatmap',
  170. coordinateSystem: 'calendar',
  171. calendarIndex: 0,
  172. data: getVirtulData(2017)
  173. }, {
  174. type: 'heatmap',
  175. coordinateSystem: 'calendar',
  176. calendarIndex: 1,
  177. data: getVirtulData(2017)
  178. }, {
  179. type: 'heatmap',
  180. coordinateSystem: 'calendar',
  181. calendarIndex: 2,
  182. data: getVirtulData(2017)
  183. }, {
  184. type: 'heatmap',
  185. coordinateSystem: 'calendar',
  186. calendarIndex: 3,
  187. data: getVirtulData(2017)
  188. }, {
  189. type: 'heatmap',
  190. coordinateSystem: 'calendar',
  191. calendarIndex: 4,
  192. data: getVirtulData(2017)
  193. }, {
  194. type: 'heatmap',
  195. coordinateSystem: 'calendar',
  196. calendarIndex: 5,
  197. data: getVirtulData(2017)
  198. }, {
  199. type: 'heatmap',
  200. coordinateSystem: 'calendar',
  201. calendarIndex: 6,
  202. data: getVirtulData(2017)
  203. }, {
  204. type: 'heatmap',
  205. coordinateSystem: 'calendar',
  206. calendarIndex: 7,
  207. data: getVirtulData(2017)
  208. }, {
  209. type: 'heatmap',
  210. coordinateSystem: 'calendar',
  211. calendarIndex: 8,
  212. data: getVirtulData(2017)
  213. }, {
  214. type: 'heatmap',
  215. coordinateSystem: 'calendar',
  216. calendarIndex: 9,
  217. data: getVirtulData(2017)
  218. }, {
  219. type: 'heatmap',
  220. coordinateSystem: 'calendar',
  221. calendarIndex: 10,
  222. data: getVirtulData(2017)
  223. }]
  224. });
  225. $(window).resize(function() {
  226. chart.resize();
  227. });
  228. });
  229. </script>
  230. </body>
  231. </html>