dataZoom-sync.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/config.js"></script>
  7. <script src="lib/jquery.min.js"></script>
  8. <script src="lib/facePrint.js"></script>
  9. <meta name="viewport" content="width=device-width, initial-scale=1" />
  10. <link rel="stylesheet" href="lib/reset.css">
  11. </head>
  12. <body>
  13. <style>
  14. h1 {
  15. line-height: 60px;
  16. height: 60px;
  17. background: #360;
  18. text-align: center;
  19. font-weight: bold;
  20. color: #eee;
  21. font-size: 14px;
  22. }
  23. .chart {
  24. height: 350px;
  25. }
  26. </style>
  27. <h1>Check dataZoom sync on two category axes with DATA MISSING and STACK and without min/max set.</h1>
  28. <div class="chart" id="sync"></div>
  29. <script>
  30. var echarts;
  31. var colorTool;
  32. var chart;
  33. var myChart;
  34. var groupCategories = [];
  35. var groupColors = [];
  36. require([
  37. 'echarts',
  38. // 'zrender/tool/color',
  39. // 'echarts/chart/line',
  40. // 'echarts/chart/parallel',
  41. // 'echarts/component/grid',
  42. // 'echarts/component/legend',
  43. // 'echarts/component/tooltip',
  44. // 'echarts/component/toolbox',
  45. // 'echarts/component/dataZoom'
  46. ], function (ec) {
  47. echarts = ec;
  48. colorTool = echarts.color;
  49. chart = myChart = echarts.init(document.getElementById('sync'));
  50. option = {
  51. dataZoom:[
  52. {type:'slider',show:'true',xAxisIndex: [0, 1] },
  53. {type:'inside',show:'true',xAxisIndex: [0, 1] }
  54. ],
  55. tooltip: {
  56. trigger: 'axis'
  57. },
  58. toolbox: {
  59. feature: {
  60. dataView: {
  61. show: true,
  62. readOnly: false
  63. },
  64. restore: {
  65. show: true
  66. },
  67. saveAsImage: {
  68. show: true
  69. }
  70. }
  71. },
  72. grid: {
  73. containLabel: true
  74. },
  75. legend: {
  76. data: ['增速','销量']
  77. },
  78. xAxis: [{
  79. type: 'category',
  80. axisTick: {
  81. alignWithLabel: true
  82. },
  83. data: ['2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015','2016']
  84. },
  85. {
  86. type: 'category',
  87. axisTick: {
  88. alignWithLabel: true
  89. },
  90. data: ['2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015','2016']
  91. }],
  92. yAxis: [{
  93. type: 'value',
  94. name: '销量',
  95. min: 0,
  96. max: 100,
  97. position: 'left'
  98. }],
  99. series: [{
  100. name: '增速',
  101. type: 'line',
  102. stack: '总量',
  103. label: {
  104. normal: {
  105. show: true,
  106. position: 'top',
  107. }
  108. },
  109. lineStyle: {
  110. normal: {
  111. width: 3,
  112. shadowColor: 'rgba(0,0,0,0.4)',
  113. shadowBlur: 10,
  114. shadowOffsetY: 10
  115. }
  116. },
  117. data: [['2000',1],['2001',13]
  118. ,['2002',37],['2003',35],['2004',15],
  119. ['2005',13],['2006',25],['2007',21],['2008',6],['2009',45]
  120. ,['2010',32],['2011',2],['2012',4],['2013',13],['2014',6],['2015',11],['2016',12]]
  121. }, {
  122. name: '销量',
  123. type: 'line',
  124. yAxisIndex: 0,
  125. xAxisIndex:1,
  126. stack: '总量',
  127. label: {
  128. normal: {
  129. show: true,
  130. position: 'top'
  131. }
  132. },
  133. data: [['2000',1],['2001',13]
  134. ,['2002',37],['2003',35],['2004',15],
  135. ['2005',13],['2006',25],['2007',21],['2008',6],['2009',45]
  136. ,['2010',32],['2011',2],['2012',4],['2013',13],['2014',6]]
  137. }]
  138. };
  139. chart.setOption(option);
  140. });
  141. </script>
  142. </body>
  143. </html>