dataZoom-cartesian-h.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. h3 {
  17. text-align: center;
  18. background: #eee;
  19. line-height: 30px;
  20. }
  21. </style>
  22. <h3>Check the highlighted label while data zooming</h3>
  23. <div id="main"></div>
  24. <script>
  25. require([
  26. 'echarts',
  27. 'echarts/chart/bar',
  28. 'echarts/chart/line',
  29. 'echarts/component/legend',
  30. 'echarts/component/grid',
  31. 'echarts/component/axis',
  32. 'echarts/component/dataZoom',
  33. 'echarts/component/tooltip',
  34. 'echarts/component/markPoint',
  35. 'echarts/component/markLine'
  36. ], function (echarts) {
  37. chart = echarts.init(document.getElementById('main'), null, {
  38. renderer: 'canvas'
  39. });
  40. var xAxisData = [];
  41. var data1 = [];
  42. var data2 = [];
  43. var data3 = [];
  44. for (var i = 0; i < 200; i++) {
  45. var data1Val;
  46. var data2Val;
  47. var data3Val;
  48. if (Math.random() < 0.03) {
  49. data1Val = '-';
  50. data2Val = '-';
  51. data3Val = '-';
  52. }
  53. else {
  54. data1Val = (Math.random() + 0.1).toFixed(2);
  55. data2Val = (Math.random() + 1).toFixed(2);
  56. data3Val = Math.random().toFixed(2);
  57. }
  58. if (i === 10 || i === 16) {
  59. xAxisData.push({
  60. value: '类目' + i,
  61. textStyle: {
  62. fontSize: 14,
  63. color: 'red',
  64. fontWeight: 'bold'
  65. }
  66. });
  67. data1.push({
  68. value: data1Val,
  69. itemStyle: {
  70. normal: {
  71. color: 'yellow'
  72. }
  73. }
  74. });
  75. data2.push(data2Val);
  76. data3.push(data3Val);
  77. }
  78. else {
  79. xAxisData.push(i);
  80. data1.push(data1Val);
  81. data2.push(data2Val);
  82. data3.push(data3Val);
  83. }
  84. }
  85. chart.setOption({
  86. legend: {
  87. data: ['bar', 'line', 'bar3']
  88. },
  89. tooltip: {
  90. trigger: 'axis'
  91. },
  92. yAxis: {
  93. data: xAxisData,
  94. boundaryGap: false
  95. },
  96. xAxis: {
  97. // inverse: true,
  98. // scale: true
  99. },
  100. series: [
  101. {
  102. name: 'line',
  103. type: 'line',
  104. // stack: 'all',
  105. data: data2,
  106. smooth: true
  107. },
  108. {
  109. name: 'bar3',
  110. type: 'bar',
  111. stack: 'all',
  112. data: data3,
  113. smooth: 0.1
  114. },
  115. {
  116. name: 'bar',
  117. type: 'bar',
  118. data: data1,
  119. smooth: true,
  120. stack: 'all',
  121. itemStyle: {
  122. normal: {
  123. areaStyle: {}
  124. }
  125. },
  126. markPoint: {
  127. data: [{
  128. type: 'max'
  129. }]
  130. },
  131. markLine: {
  132. data: [
  133. [{
  134. type: 'average'
  135. }, {
  136. type: 'max'
  137. }]
  138. ]
  139. }
  140. }
  141. ],
  142. dataZoom: [
  143. {
  144. show: true,
  145. startValue: 2,
  146. end: 30,
  147. borderColor: 'rgba(0,0,0,0.15)',
  148. backgroundColor: 'rgba(200,200,200,0)',
  149. yAxisIndex: 0
  150. },
  151. {
  152. type: 'inside',
  153. startValue: 2,
  154. end: 30,
  155. yAxisIndex: 0
  156. }
  157. ]
  158. });
  159. })
  160. </script>
  161. </body>
  162. </html>