line-animation.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/config.js"></script>
  7. <script src="lib/jquery.min.js"></script>
  8. <script src="lib/facePrint.js"></script>
  9. <script src="lib/testHelper.js"></script>
  10. <meta name="viewport" content="width=device-width, initial-scale=1" />
  11. <link rel="stylesheet" href="lib/reset.css">
  12. </head>
  13. <body>
  14. <style>
  15. h1 {
  16. line-height: 60px;
  17. height: 60px;
  18. background: #146402;
  19. text-align: center;
  20. font-weight: bold;
  21. color: #eee;
  22. font-size: 14px;
  23. }
  24. .chart {
  25. height: 500px;
  26. }
  27. button {
  28. font-size: 16px;
  29. }
  30. </style>
  31. <button onclick="change()">CHANGE</button>
  32. <div class="chart" id="main"></div>
  33. <script>
  34. var echarts;
  35. var chart;
  36. var myChart;
  37. var groupCategories = [];
  38. var groupColors = [];
  39. require([
  40. 'echarts'
  41. // 'echarts/chart/line',
  42. // 'echarts/chart/bar',
  43. // 'echarts/chart/pie',
  44. // 'echarts/chart/scatter',
  45. // 'echarts/chart/map',
  46. // 'echarts/chart/parallel',
  47. // 'echarts/chart/radar',
  48. // 'echarts/component/grid',
  49. // 'echarts/component/polar',
  50. // 'echarts/component/geo',
  51. // 'echarts/component/singleAxis',
  52. // 'echarts/component/legend',
  53. // 'echarts/component/tooltip',
  54. // 'echarts/component/toolbox',
  55. // 'echarts/component/visualMap',
  56. // 'echarts/component/dataZoom'
  57. ], function (ec) {
  58. echarts = ec;
  59. chart = myChart = echarts.init(document.getElementById('main'));
  60. var base = +new Date(1968, 9, 3);
  61. var oneDay = 24 * 3600 * 1000;
  62. var date = [];
  63. var data = [];
  64. for (var i = 0; i < 10; i++) {
  65. var now = new Date(base += oneDay);
  66. date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'));
  67. // data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
  68. data.push(i * i);
  69. }
  70. option = {
  71. tooltip: {
  72. trigger: 'axis',
  73. position: function (pt) {
  74. return [pt[0], '10%'];
  75. }
  76. },
  77. legend: {
  78. data: ['large area']
  79. },
  80. toolbox: {
  81. feature: {
  82. dataZoom: {
  83. yAxisIndex: 'none'
  84. },
  85. restore: {},
  86. saveAsImage: {}
  87. }
  88. },
  89. grid: {
  90. containLabel: true
  91. },
  92. xAxis: {
  93. type: 'category',
  94. boundaryGap: false,
  95. data: date,
  96. axisTick: {
  97. interval: 0
  98. },
  99. axisLabel: {
  100. interval: 0
  101. }
  102. },
  103. yAxis: {
  104. type: 'value',
  105. boundaryGap: [0, '100%']
  106. },
  107. dataZoom: [{
  108. type: 'inside',
  109. // start: 0,
  110. // end: 10
  111. }, {
  112. start: 0,
  113. end: 10,
  114. handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
  115. handleSize: '80%',
  116. handleStyle: {
  117. color: '#fff',
  118. shadowBlur: 3,
  119. shadowColor: 'rgba(0, 0, 0, 0.6)',
  120. shadowOffsetX: 2,
  121. shadowOffsetY: 2
  122. }
  123. }],
  124. series: [
  125. {
  126. name:'large area',
  127. type:'line',
  128. // type:'scatter',
  129. // smooth:true,
  130. // symbol: 'none',
  131. sampling: 'average',
  132. itemStyle: {
  133. normal: {
  134. color: 'rgb(255, 70, 131)'
  135. }
  136. },
  137. lineStyle: {
  138. normal: {
  139. shadowBlur: 6,
  140. shadowColor: '#999',
  141. shadowOffsetX: 10,
  142. shadowOffsetY: 10
  143. }
  144. },
  145. // areaStyle: {
  146. // normal: {
  147. // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  148. // offset: 0,
  149. // color: 'rgb(255, 158, 68)'
  150. // }, {
  151. // offset: 1,
  152. // color: 'rgb(255, 70, 131)'
  153. // }])
  154. // }
  155. // },
  156. data: data
  157. }
  158. ],
  159. animationDurationUpdate: 3000
  160. };
  161. chart.setOption(option);
  162. });
  163. function change() {
  164. chart.dispatchAction({
  165. type: 'dataZoom',
  166. end: 20
  167. });
  168. }
  169. </script>
  170. </body>
  171. </html>