axisPosition.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. <script src="lib/testHelper.js"></script>
  10. <meta name="viewport" content="width=device-width, initial-scale=1" />
  11. <link rel="stylesheet" href="lib/reset.css">
  12. </head>
  13. <body>
  14. <style>
  15. h1 {
  16. line-height: 60px;
  17. height: 60px;
  18. background: #146402;
  19. text-align: center;
  20. font-weight: bold;
  21. color: #eee;
  22. font-size: 14px;
  23. }
  24. .chart {
  25. height: 500px;
  26. }
  27. </style>
  28. <h1>right y: min/max set, should not effect onZero of left y. (pick the first axis that can on zero)</h1>
  29. <div class="chart" id="a"></div>
  30. <h1>onZeroAxisIndex specified (onZero on the right y axis)</h1>
  31. <div class="chart" id="b"></div>
  32. <script>
  33. var echarts;
  34. var chart;
  35. var myChart;
  36. var groupCategories = [];
  37. var groupColors = [];
  38. require([
  39. 'echarts'
  40. // 'echarts/chart/line',
  41. // 'echarts/chart/bar',
  42. // 'echarts/chart/pie',
  43. // 'echarts/chart/scatter',
  44. // 'echarts/chart/map',
  45. // 'echarts/chart/parallel',
  46. // 'echarts/chart/radar',
  47. // 'echarts/component/grid',
  48. // 'echarts/component/polar',
  49. // 'echarts/component/geo',
  50. // 'echarts/component/singleAxis',
  51. // 'echarts/component/legend',
  52. // 'echarts/component/tooltip',
  53. // 'echarts/component/toolbox',
  54. // 'echarts/component/visualMap',
  55. // 'echarts/component/dataZoom'
  56. ], function (ec) {
  57. echarts = ec;
  58. chart = myChart = echarts.init(document.getElementById('a'));
  59. option = {
  60. legend: {
  61. data: ['left', 'right']
  62. },
  63. xAxis : [
  64. {
  65. type : 'category',
  66. data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  67. }
  68. ],
  69. yAxis : [
  70. {
  71. type : 'value'
  72. },
  73. {
  74. type: 'value',
  75. axisLabel: {
  76. formatter: '{value} %'
  77. },
  78. min: 1,
  79. max: 80
  80. }
  81. ],
  82. series : [
  83. {
  84. name: 'left',
  85. type: 'bar',
  86. // barWidth: '60%',
  87. data:[1000, -520, -2000, -3340, 3900, -330, -5220]
  88. },
  89. {
  90. name: 'right',
  91. type: 'line',
  92. yAxisIndex: 1,
  93. data: [10, 0, 30, 50]
  94. }
  95. ]
  96. };
  97. chart.setOption(option);
  98. });
  99. </script>
  100. <script>
  101. var echarts;
  102. var chart;
  103. var myChart;
  104. var groupCategories = [];
  105. var groupColors = [];
  106. require([
  107. 'echarts'
  108. // 'echarts/chart/line',
  109. // 'echarts/chart/bar',
  110. // 'echarts/chart/pie',
  111. // 'echarts/chart/scatter',
  112. // 'echarts/chart/map',
  113. // 'echarts/chart/parallel',
  114. // 'echarts/chart/radar',
  115. // 'echarts/component/grid',
  116. // 'echarts/component/polar',
  117. // 'echarts/component/geo',
  118. // 'echarts/component/singleAxis',
  119. // 'echarts/component/legend',
  120. // 'echarts/component/tooltip',
  121. // 'echarts/component/toolbox',
  122. // 'echarts/component/visualMap',
  123. // 'echarts/component/dataZoom'
  124. ], function (ec) {
  125. echarts = ec;
  126. chart = myChart = echarts.init(document.getElementById('b'));
  127. option = {
  128. legend: {
  129. data: ['left', 'right']
  130. },
  131. xAxis : [
  132. {
  133. type : 'category',
  134. axisLine: {
  135. onZero: true,
  136. onZeroAxisIndex: 1
  137. },
  138. data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  139. }
  140. ],
  141. yAxis : [
  142. {
  143. type : 'value'
  144. },
  145. {
  146. type: 'value',
  147. axisLabel: {
  148. formatter: '{value} %'
  149. }
  150. }
  151. ],
  152. series : [
  153. {
  154. name: 'left',
  155. type: 'line',
  156. data:[1000, -520, -2000, -3340, 3900, -330, -5220]
  157. },
  158. {
  159. name: 'right',
  160. type: 'line',
  161. yAxisIndex: 1,
  162. data: [-10, 0, 30, 50]
  163. }
  164. ]
  165. };
  166. chart.setOption(option);
  167. });
  168. </script>
  169. </body>
  170. </html>