dataZoom-rainfall-inside.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="./esl.js"></script>
  6. <script src="./config.js"></script>
  7. <script src="./lib/facePrint.js"></script>
  8. </head>
  9. <body>
  10. <style>
  11. html,
  12. body,
  13. #main {
  14. width: 100%;
  15. height: 100%;
  16. margin: 0;
  17. padding: 0;
  18. }
  19. </style>
  20. <div id="main"></div>
  21. <script>
  22. require([
  23. 'data/rainfall.json',
  24. 'echarts',
  25. 'zrender/vml/vml',
  26. 'echarts/chart/bar',
  27. 'echarts/chart/line',
  28. 'echarts/component/legend',
  29. 'echarts/component/tooltip',
  30. 'echarts/component/grid',
  31. 'echarts/component/axis',
  32. 'echarts/component/dataZoomInside'
  33. ], function (data, echarts) {
  34. var chart = echarts.init(document.getElementById('main'), null, {
  35. renderer: 'canvas'
  36. });
  37. chart.showLoading({
  38. text : '正在读取数据中...'
  39. });
  40. var xAxisData = [];
  41. var data1 = [];
  42. var data2 = [];
  43. var data3 = [];
  44. for (var i = 0; i < 20; i++) {
  45. xAxisData.push('类目' + i);
  46. data1.push(Math.random() * 2);
  47. data2.push(Math.random() * 2);
  48. data3.push(Math.random() * 2);
  49. }
  50. chart.setOption({
  51. tooltip: {
  52. trigger: 'axis',
  53. },
  54. legend: {
  55. data: ['降水量', '流量']
  56. },
  57. grid: [
  58. {
  59. show: true,
  60. borderWidth: 0,
  61. right: '15%',
  62. bottom: '53%'
  63. },
  64. {
  65. show: true,
  66. borderWidth: 0,
  67. right: '15%',
  68. top: '53%'
  69. }
  70. ],
  71. xAxis: [
  72. {
  73. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  74. // data: xAxisData,
  75. type: 'category',
  76. boundaryGap: true,
  77. // splitLine: {show: false},
  78. axisLabel: {show: true},
  79. splitLine: {show: false},
  80. axisLine: {
  81. show: true,
  82. // onZero: false
  83. },
  84. data: data.category,
  85. gridIndex: 0
  86. },
  87. {
  88. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  89. // data: xAxisData,
  90. type: 'category',
  91. boundaryGap: true,
  92. axisLabel: {show: true},
  93. splitLine: {show: false},
  94. axisLine: {
  95. show: true,
  96. },
  97. data: data.category,
  98. gridIndex: 1
  99. }
  100. ],
  101. yAxis: [
  102. {
  103. boundaryGap: false,
  104. axisLabel: {
  105. },
  106. axisLine: {
  107. lineStyle: {
  108. color: '#666'
  109. }
  110. },
  111. gridIndex: 0
  112. },
  113. {
  114. boundaryGap: false,
  115. position: 'right',
  116. inverse: true,
  117. axisLabel: {
  118. textStyle: {
  119. color: '#666'
  120. }
  121. },
  122. axisLine: {
  123. lineStyle: {
  124. color: '#666'
  125. }
  126. },
  127. gridIndex: 1
  128. }
  129. ],
  130. series: [
  131. {
  132. name: '降水量',
  133. type: 'line',
  134. data: data.rainfall,
  135. itemStyle: {
  136. normal: {
  137. areaStyle: {}
  138. }
  139. },
  140. xAxisIndex: 0,
  141. yAxisIndex: 0,
  142. },
  143. {
  144. name: '流量',
  145. type: 'line',
  146. data: data.flow,
  147. itemStyle: {
  148. normal: {
  149. areaStyle: {}
  150. }
  151. },
  152. xAxisIndex: 1,
  153. yAxisIndex: 1
  154. }
  155. ],
  156. dataZoom: [
  157. {
  158. type: 'inside',
  159. xAxisIndex: [0, 1],
  160. start: 30,
  161. end: 40
  162. }
  163. ]
  164. });
  165. chart.hideLoading();
  166. })
  167. </script>
  168. </body>
  169. </html>