calendar-year.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. yearLabel: {
  66. position: 'top'
  67. },
  68. range: '2017-01'
  69. },
  70. {
  71. yearLabel: {
  72. position: 'bottom'
  73. },
  74. left: 300,
  75. range: '2017-02'
  76. },
  77. {
  78. yearLabel: {
  79. position: 'left'
  80. },
  81. left: 550,
  82. range: '2017-03'
  83. },
  84. {
  85. yearLabel: {
  86. position: 'right'
  87. },
  88. left: 750,
  89. range: '2017-04'
  90. },
  91. {
  92. left: 1000,
  93. range: ['2017-12-01', '2018-01-31']
  94. },
  95. {
  96. yearLabel: {
  97. position: 'top'
  98. },
  99. top: 320,
  100. orient: 'vertical',
  101. range: '2017-01'
  102. },
  103. {
  104. yearLabel: {
  105. position: 'bottom'
  106. },
  107. top: 320,
  108. left: 300,
  109. orient: 'vertical',
  110. range: '2017-02'
  111. },
  112. {
  113. yearLabel: {
  114. position: 'left'
  115. },
  116. top: 320,
  117. orient: 'vertical',
  118. left: 550,
  119. range: '2017-03'
  120. },
  121. {
  122. yearLabel: {
  123. position: 'right'
  124. },
  125. top: 320,
  126. orient: 'vertical',
  127. left: 750,
  128. range: '2017-04'
  129. },
  130. {
  131. yearLabel: {
  132. margin: 50,
  133. formatter: function (opt) {
  134. return '年份区间: ' + opt.start + '-' + opt.end;
  135. },
  136. textStyle: {
  137. color: '#009688',
  138. fontStyle: 'italic',
  139. fontFamily: 'sans-serif',
  140. fontWeight: 'bolder',
  141. fontSize: 20
  142. }
  143. },
  144. top: 320,
  145. orient: 'vertical',
  146. left: 1000,
  147. range: ['2017-12-01', '2018-01-31']
  148. }],
  149. series: [{
  150. type: 'heatmap',
  151. coordinateSystem: 'calendar',
  152. calendarIndex: 0,
  153. data: getVirtulData(2017)
  154. }, {
  155. type: 'heatmap',
  156. coordinateSystem: 'calendar',
  157. calendarIndex: 1,
  158. data: getVirtulData(2017)
  159. }, {
  160. type: 'heatmap',
  161. coordinateSystem: 'calendar',
  162. calendarIndex: 2,
  163. data: getVirtulData(2017)
  164. }, {
  165. type: 'heatmap',
  166. coordinateSystem: 'calendar',
  167. calendarIndex: 3,
  168. data: getVirtulData(2017)
  169. }, {
  170. type: 'heatmap',
  171. coordinateSystem: 'calendar',
  172. calendarIndex: 4,
  173. data: getVirtulData(2017)
  174. }, {
  175. type: 'heatmap',
  176. coordinateSystem: 'calendar',
  177. calendarIndex: 5,
  178. data: getVirtulData(2017)
  179. }, {
  180. type: 'heatmap',
  181. coordinateSystem: 'calendar',
  182. calendarIndex: 6,
  183. data: getVirtulData(2017)
  184. }, {
  185. type: 'heatmap',
  186. coordinateSystem: 'calendar',
  187. calendarIndex: 7,
  188. data: getVirtulData(2017)
  189. }, {
  190. type: 'heatmap',
  191. coordinateSystem: 'calendar',
  192. calendarIndex: 8,
  193. data: getVirtulData(2017)
  194. }, {
  195. type: 'heatmap',
  196. coordinateSystem: 'calendar',
  197. calendarIndex: 9,
  198. data: getVirtulData(2017)
  199. }]
  200. });
  201. $(window).resize(function() {
  202. chart.resize();
  203. });
  204. });
  205. </script>
  206. </body>
  207. </html>