dataZoom-rainfall-inside.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="./lib/esl.js"></script>
  6. <script src="./lib/config.js"></script>
  7. <script src="./lib/facePrint.js"></script>
  8. <script src="lib/testHelper.js"></script>
  9. <link rel="stylesheet" href="lib/reset.css" />
  10. </head>
  11. <body>
  12. <style>
  13. h1 {
  14. line-height: 60px;
  15. height: 60px;
  16. background: #ddd;
  17. text-align: center;
  18. font-weight: bold;
  19. font-size: 14px;
  20. }
  21. .chart {
  22. height: 500px;
  23. }
  24. </style>
  25. <h1>rainfall</h1>
  26. <div class="chart" id="rainfall"></div>
  27. <h1>zoom lock | Should not prevent default when mouse wheel.</h1>
  28. <div class="chart" id="zoom-lock"></div>
  29. <h1>zoomOnMouseWheel: 'shift', moveOnMouseMove: 'alt' | Should not prevent default when mouse wheel.</h1>
  30. <div class="chart" id="zoom-shift"></div>
  31. <script>
  32. require([
  33. 'data/rainfall.json',
  34. 'echarts'
  35. // 'zrender/vml/vml',
  36. // 'echarts/chart/bar',
  37. // 'echarts/chart/line',
  38. // 'echarts/component/legend',
  39. // 'echarts/component/tooltip',
  40. // 'echarts/component/grid',
  41. // 'echarts/component/axis',
  42. // 'echarts/component/dataZoomInside'
  43. ], function (data, echarts) {
  44. var chart = echarts.init(document.getElementById('rainfall'));
  45. var option = {
  46. tooltip: {
  47. trigger: 'axis',
  48. },
  49. legend: {
  50. data: ['降水量', '流量']
  51. },
  52. grid: [
  53. {
  54. show: true,
  55. borderWidth: 0,
  56. right: '15%',
  57. bottom: '53%'
  58. },
  59. {
  60. show: true,
  61. borderWidth: 0,
  62. right: '15%',
  63. top: '53%'
  64. }
  65. ],
  66. xAxis: [
  67. {
  68. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  69. // data: xAxisData,
  70. type: 'category',
  71. boundaryGap: true,
  72. // splitLine: {show: false},
  73. axisLabel: {show: true},
  74. splitLine: {show: false},
  75. axisLine: {
  76. show: true,
  77. // onZero: false
  78. },
  79. data: data.category,
  80. gridIndex: 0
  81. },
  82. {
  83. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  84. // data: xAxisData,
  85. type: 'category',
  86. boundaryGap: true,
  87. axisLabel: {show: true},
  88. splitLine: {show: false},
  89. axisLine: {
  90. show: true,
  91. },
  92. data: data.category,
  93. gridIndex: 1
  94. }
  95. ],
  96. yAxis: [
  97. {
  98. boundaryGap: false,
  99. axisLabel: {
  100. },
  101. axisLine: {
  102. lineStyle: {
  103. color: '#666'
  104. }
  105. },
  106. gridIndex: 0
  107. },
  108. {
  109. boundaryGap: false,
  110. position: 'right',
  111. inverse: true,
  112. axisLabel: {
  113. textStyle: {
  114. color: '#666'
  115. }
  116. },
  117. axisLine: {
  118. lineStyle: {
  119. color: '#666'
  120. }
  121. },
  122. gridIndex: 1
  123. }
  124. ],
  125. series: [
  126. {
  127. name: '降水量',
  128. type: 'line',
  129. data: data.rainfall,
  130. itemStyle: {
  131. normal: {
  132. areaStyle: {}
  133. }
  134. },
  135. xAxisIndex: 0,
  136. yAxisIndex: 0,
  137. },
  138. {
  139. name: '流量',
  140. type: 'line',
  141. data: data.flow,
  142. itemStyle: {
  143. normal: {
  144. areaStyle: {}
  145. }
  146. },
  147. xAxisIndex: 1,
  148. yAxisIndex: 1
  149. }
  150. ],
  151. dataZoom: [
  152. {
  153. type: 'inside',
  154. xAxisIndex: [0, 1],
  155. start: 30,
  156. end: 40
  157. }
  158. ]
  159. };
  160. testHelper.createChart(echarts, 'rainfall', option);
  161. })
  162. </script>
  163. <script>
  164. require([
  165. 'data/rainfall.json',
  166. 'echarts'
  167. // 'zrender/vml/vml',
  168. // 'echarts/chart/bar',
  169. // 'echarts/chart/line',
  170. // 'echarts/component/legend',
  171. // 'echarts/component/tooltip',
  172. // 'echarts/component/grid',
  173. // 'echarts/component/axis',
  174. // 'echarts/component/dataZoom'
  175. ], function (data, echarts) {
  176. var chart = echarts.init(document.getElementById('zoom-lock'));
  177. var option = {
  178. tooltip: {
  179. trigger: 'axis',
  180. },
  181. grid: [
  182. {
  183. show: true,
  184. borderWidth: 0
  185. }
  186. ],
  187. xAxis: [
  188. {
  189. type: 'category',
  190. boundaryGap: true,
  191. axisLabel: {show: true},
  192. splitLine: {show: false},
  193. data: data.category,
  194. gridIndex: 0
  195. }
  196. ],
  197. yAxis: [
  198. {
  199. boundaryGap: false,
  200. axisLabel: {
  201. },
  202. axisLine: {
  203. lineStyle: {
  204. color: '#666'
  205. }
  206. },
  207. gridIndex: 0
  208. }
  209. ],
  210. series: [
  211. {
  212. name: '降水量',
  213. type: 'line',
  214. data: data.rainfall,
  215. itemStyle: {
  216. normal: {
  217. areaStyle: {}
  218. }
  219. },
  220. xAxisIndex: 0,
  221. yAxisIndex: 0,
  222. }
  223. ],
  224. dataZoom: [
  225. {
  226. type: 'inside',
  227. zoomLock: true,
  228. start: 30,
  229. end: 40
  230. },
  231. {
  232. type: 'slider',
  233. start: 30,
  234. end: 40
  235. },
  236. {
  237. type: 'slider',
  238. yAxisIndex: 0
  239. }
  240. ]
  241. };
  242. testHelper.createChart(echarts, 'zoom-lock', option);
  243. })
  244. </script>
  245. <script>
  246. require([
  247. 'data/rainfall.json',
  248. 'echarts'
  249. // 'zrender/vml/vml',
  250. // 'echarts/chart/bar',
  251. // 'echarts/chart/line',
  252. // 'echarts/component/legend',
  253. // 'echarts/component/tooltip',
  254. // 'echarts/component/grid',
  255. // 'echarts/component/axis',
  256. // 'echarts/component/dataZoom'
  257. ], function (data, echarts) {
  258. var option = {
  259. tooltip: {
  260. trigger: 'axis'
  261. },
  262. grid: [
  263. {
  264. show: true,
  265. borderWidth: 0
  266. }
  267. ],
  268. xAxis: [
  269. {
  270. type: 'category',
  271. boundaryGap: true,
  272. axisLabel: {show: true},
  273. splitLine: {show: false},
  274. data: data.category,
  275. gridIndex: 0
  276. }
  277. ],
  278. yAxis: [
  279. {
  280. boundaryGap: false,
  281. axisLabel: {
  282. },
  283. axisLine: {
  284. lineStyle: {
  285. color: '#666'
  286. }
  287. },
  288. gridIndex: 0
  289. }
  290. ],
  291. series: [
  292. {
  293. name: '降水量',
  294. type: 'line',
  295. data: data.rainfall,
  296. itemStyle: {
  297. normal: {
  298. areaStyle: {}
  299. }
  300. },
  301. xAxisIndex: 0,
  302. yAxisIndex: 0,
  303. }
  304. ],
  305. dataZoom: [
  306. {
  307. type: 'inside',
  308. zoomOnMouseWheel: 'shift',
  309. moveOnMouseMove: 'alt',
  310. start: 30,
  311. end: 40
  312. },
  313. {
  314. type: 'slider',
  315. start: 30,
  316. end: 40
  317. },
  318. {
  319. type: 'slider',
  320. yAxisIndex: 0
  321. }
  322. ]
  323. };
  324. testHelper.createChart(echarts, 'zoom-shift', option);
  325. })
  326. </script>
  327. </body>
  328. </html>