dataZoom-cartesian-v.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. </head>
  7. <body>
  8. <style>
  9. html, body, #main {
  10. width: 100%;
  11. height: 100%;
  12. }
  13. </style>
  14. <div id="main"></div>
  15. <script>
  16. require([
  17. 'echarts',
  18. 'echarts/chart/bar',
  19. 'echarts/component/legend',
  20. 'echarts/component/grid',
  21. 'echarts/component/axis',
  22. 'echarts/component/dataZoom'
  23. ], function (echarts) {
  24. var chart = echarts.init(document.getElementById('main'), null, {
  25. renderer: 'canvas'
  26. });
  27. var xAxisData = [];
  28. var data1 = [];
  29. var data2 = [];
  30. var data3 = [];
  31. for (var i = 0; i < 20; i++) {
  32. xAxisData.push('类目' + i);
  33. data1.push(Math.random() * 2);
  34. data2.push(Math.random() * 2);
  35. data3.push(Math.random() * 2);
  36. }
  37. chart.setOption({
  38. legend: {
  39. data: ['bar', 'bar2', 'bar3']
  40. },
  41. xAxis: {
  42. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  43. data: xAxisData,
  44. boundaryGap: true
  45. },
  46. yAxis: {
  47. // scale: true
  48. boundaryGap: false
  49. },
  50. series: [
  51. {
  52. name: 'bar',
  53. type: 'bar',
  54. data: data1
  55. },
  56. {
  57. name: 'bar2',
  58. type: 'bar',
  59. data: data2
  60. },
  61. {
  62. name: 'bar3',
  63. type: 'bar',
  64. data: data3
  65. }
  66. ],
  67. dataZoom: {
  68. show: true,
  69. orient: 'vertical',
  70. yAxisIndex: [0]
  71. }
  72. });
  73. })
  74. </script>
  75. </body>
  76. </html>