dataZoom-cartesian-h.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. body {
  14. margin: 0;
  15. }
  16. </style>
  17. <div id="main"></div>
  18. <script>
  19. require([
  20. 'echarts',
  21. 'echarts/chart/bar',
  22. 'echarts/component/legend',
  23. 'echarts/component/grid',
  24. 'echarts/component/axis',
  25. 'echarts/component/dataZoom',
  26. 'echarts/component/tooltip',
  27. 'echarts/component/markPoint',
  28. 'echarts/component/markLine'
  29. ], function (echarts) {
  30. chart = echarts.init(document.getElementById('main'), null, {
  31. renderer: 'canvas'
  32. });
  33. var xAxisData = [];
  34. var data1 = [];
  35. var data2 = [];
  36. var data3 = [];
  37. for (var i = 0; i < 200; i++) {
  38. xAxisData.push('类目' + i);
  39. if (Math.random() < 0.03) {
  40. data1.push('-');
  41. data2.push('-');
  42. data3.push('-');
  43. }
  44. else {
  45. data1.push((Math.random() + 0.1).toFixed(2));
  46. data2.push(Math.random().toFixed(2));
  47. data3.push(Math.random().toFixed(2));
  48. }
  49. }
  50. chart.setOption({
  51. legend: {
  52. data: ['bar', 'bar2', 'bar3']
  53. },
  54. tooltip: {
  55. trigger: 'axis'
  56. },
  57. yAxis: {
  58. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  59. data: xAxisData,
  60. boundaryGap: false
  61. },
  62. xAxis: {
  63. // inverse: true,
  64. // scale: true
  65. },
  66. series: [
  67. {
  68. name: 'bar2',
  69. type: 'bar',
  70. stack: 'all',
  71. data: data2,
  72. smooth: true
  73. },
  74. {
  75. name: 'bar3',
  76. type: 'bar',
  77. stack: 'all',
  78. data: data3,
  79. smooth: 0.1
  80. },
  81. {
  82. name: 'bar',
  83. type: 'bar',
  84. data: data1,
  85. smooth: true,
  86. stack: 'all',
  87. itemStyle: {
  88. normal: {
  89. areaStyle: {}
  90. }
  91. },
  92. markPoint: {
  93. data: [{
  94. type: 'max'
  95. }]
  96. },
  97. markLine: {
  98. data: [
  99. [{
  100. type: 'average'
  101. }, {
  102. type: 'max'
  103. }]
  104. ]
  105. }
  106. }
  107. ],
  108. dataZoom: {
  109. show: true,
  110. end: 30,
  111. borderColor: 'rgba(0,0,0,0.15)',
  112. backgroundColor: 'rgba(200,200,200,0)',
  113. yAxisIndex: 0
  114. }
  115. });
  116. })
  117. </script>
  118. </body>
  119. </html>