dataZoom-rainfall.html 5.6 KB

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