axis-boundaryGap.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. background: #140;
  17. text-align: center;
  18. font-weight: bold;
  19. color: #eee;
  20. font-size: 14px;
  21. }
  22. .chart {
  23. height: 200px;
  24. }
  25. </style>
  26. <h1>default {boundaryGap:true, alignWithLabel: false}, in category axis, axis tick and label should be consistent</h1>
  27. <div class="chart" id="a"></div>
  28. <script>
  29. require([
  30. 'echarts'
  31. // 'echarts/chart/line',
  32. // 'echarts/chart/bar',
  33. // 'echarts/chart/candlestick',
  34. // 'echarts/component/grid',
  35. // 'echarts/component/graphic',
  36. // 'echarts/component/legend',
  37. // 'echarts/component/tooltip',
  38. // 'echarts/component/toolbox',
  39. // 'echarts/component/dataZoom'
  40. ], function (echarts) {
  41. var axisData = [
  42. "2013/1/24", "2013/1/25", "2013/1/28", "2013/1/29", "2013/1/30",
  43. "2013/1/31", "2013/2/1", "2013/2/4", "2013/2/5", "2013/2/6",
  44. "2013/2/7", "2013/2/8", "2013/2/18", "2013/2/19", "2013/2/20",
  45. "2013/2/21", "2013/2/22", "2013/2/25", "2013/2/26", "2013/2/27",
  46. "2013/2/28", "2013/3/1", "2013/3/4", "2013/3/5", "2013/3/6",
  47. "2013/3/7", "2013/3/8", "2013/3/11", "2013/3/12", "2013/3/13",
  48. "2013/3/14", "2013/3/15", "2013/3/18", "2013/3/19", "2013/3/20",
  49. "2013/3/21", "2013/3/22", "2013/3/25", "2013/3/26", "2013/3/27",
  50. "2013/3/28", "2013/3/29", "2013/4/1", "2013/4/2", "2013/4/3",
  51. "2013/4/8", "2013/4/9", "2013/4/10", "2013/4/11", "2013/4/12",
  52. "2013/4/15", "2013/4/16", "2013/4/17", "2013/4/18", "2013/4/19",
  53. "2013/4/22", "2013/4/23", "2013/4/24", "2013/4/25", "2013/4/26",
  54. "2013/5/2", "2013/5/3", "2013/5/6", "2013/5/7", "2013/5/8",
  55. "2013/5/9", "2013/5/10", "2013/5/13", "2013/5/14", "2013/5/15",
  56. "2013/5/16", "2013/5/17", "2013/5/20", "2013/5/21", "2013/5/22",
  57. "2013/5/23", "2013/5/24", "2013/5/27", "2013/5/28", "2013/5/29",
  58. "2013/5/30", "2013/5/31", "2013/6/3", "2013/6/4", "2013/6/5",
  59. "2013/6/6", "2013/6/7", "2013/6/13"
  60. ];
  61. var option = {
  62. tooltip : {
  63. trigger: 'axis',
  64. },
  65. legend: {
  66. y : -30,
  67. data:['上证指数','成交金额(万)','虚拟数据']
  68. },
  69. dataZoom : {
  70. show : true,
  71. realtime: true,
  72. start : 50,
  73. end : 70
  74. },
  75. grid: {
  76. x: 80,
  77. y: 20,
  78. x2: 20,
  79. y2: 60
  80. },
  81. xAxis : [
  82. {
  83. type : 'category',
  84. // axisTick: {
  85. // alignWithLabel: true
  86. // },
  87. boundaryGap : true,
  88. data : axisData
  89. }
  90. ],
  91. yAxis : [
  92. {
  93. type : 'value',
  94. splitArea : {show : true}
  95. }
  96. ],
  97. series : [
  98. {
  99. name:'成交金额(万)',
  100. type:'line',
  101. data:[
  102. 13560434, 8026738.5, 11691637, 12491697, 12485603,
  103. 11620504, 12555496, 15253370, 12709611, 10458354,
  104. 10933507, 9896523, 10365702, 10633095, 9722230,
  105. 12662783, 8757982, 7764234, 10591719, 8826293,
  106. 11591827, 11153111, 14304651, 11672120, 12536480,
  107. 12608589, 8843860, 7391994.5, 10063709, 7768895.5,
  108. 6921859, 10157810, 8148617.5, 7551207, 11397426,
  109. 10478607, 8595132, 8541862, 9181132, 8570842,
  110. 10759351, 7335819, 6699753.5, 7759666.5, 6880135.5,
  111. 7366616.5, 7313504, 7109021.5, 6213270, 5619688,
  112. 5816217.5, 6695584.5, 5998655.5, 6188812.5, 9538301,
  113. 8224500, 8221751.5, 7897721, 8448324, 6525151,
  114. 5987761, 7831570, 8162560.5, 7904092, 8139084.5,
  115. 9116529, 8128014, 7919148, 7566047, 6665826.5,
  116. 10225527, 11124881, 12884353, 11302521, 11529046,
  117. 11105205, 9202153, 9992016, 12035250, 11431155,
  118. 10354677, 10070399, 9164861, 9237718, 7114268,
  119. 7526158.5, 8105835, 7971452.5
  120. ]
  121. }
  122. ]
  123. };
  124. chart = myChart = echarts.init(document.getElementById('a'));
  125. chart.setOption(option);
  126. });
  127. </script>
  128. </body>
  129. </html>