axis-lastLabel.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. <script src="lib/facePrint.js"></script>
  7. <meta name="viewport" content="width=device-width, initial-scale=1" />
  8. <link rel="stylesheet" href="lib/reset.css" />
  9. </head>
  10. <body>
  11. <style>
  12. h1 {
  13. line-height: 60px;
  14. background: #360;
  15. text-align: center;
  16. font-weight: bold;
  17. color: #eee;
  18. font-size: 14px;
  19. margin: 0;
  20. }
  21. .chart {
  22. height: 350px;
  23. }
  24. </style>
  25. <h1>xAxis: {showMinLabel: null, showMaxLabel: null (auto)}. The last x label should not be displayed (overlap).</h1>
  26. <div class="chart" id="chart-1"></div>
  27. <h1>xAxis: {showMinLabel: null, showMaxLabel: null (auto)}. The last x label shoule be displayed (not overlap).</h1>
  28. <div class="chart" id="chart0"></div>
  29. <h1>xAxis: {showMinLabel: true, showMaxLabel: true}, yAxis: {showMaxLabel: false}. The last x label should be displayed. 100 on y should not be displayed.</h1>
  30. <div class="chart" id="chart1"></div>
  31. <script>
  32. require([
  33. 'data/rainfall.json',
  34. 'echarts'
  35. // 'echarts/chart/line',
  36. // 'echarts/component/legend',
  37. // 'echarts/component/grid',
  38. // 'echarts/component/tooltip',
  39. // 'echarts/component/title',
  40. // 'echarts/component/dataZoom',
  41. // 'echarts/scale/Time'
  42. ], function (rainfallData, echarts) {
  43. var chart = echarts.init(document.getElementById('chart-1'), null, {
  44. });
  45. chart.setOption({
  46. tooltip : {
  47. trigger: 'axis'
  48. },
  49. grid: {
  50. bottom: 150
  51. },
  52. dataZoom: {
  53. show: true,
  54. realtime: true,
  55. startValue: '2009-09-20 12:00',
  56. end: 100
  57. },
  58. xAxis : [
  59. {
  60. type : 'time',
  61. // splitNumber: 20,
  62. axisLabel: {
  63. formatter: function (value) {
  64. return echarts.format.formatTime('yyyy-MM-dd hh:mm:ss', value);
  65. }
  66. }
  67. }
  68. ],
  69. yAxis : [
  70. {
  71. name: '流量(m^3/s)'
  72. }
  73. ],
  74. series : [
  75. {
  76. name: '流量',
  77. type: 'line',
  78. symbol: 'none',
  79. itemStyle: {normal: {areaStyle: {type: 'default'}}},
  80. data: rainfallData.flow.map(function (val, idx) {
  81. return [+(new Date(rainfallData.category[idx])), val];
  82. })
  83. }
  84. ]
  85. });
  86. })
  87. </script>
  88. <script>
  89. require([
  90. 'data/rainfall.json',
  91. 'echarts'
  92. // 'echarts/chart/line',
  93. // 'echarts/component/legend',
  94. // 'echarts/component/grid',
  95. // 'echarts/component/tooltip',
  96. // 'echarts/component/title',
  97. // 'echarts/component/dataZoom',
  98. // 'echarts/scale/Time'
  99. ], function (rainfallData, echarts) {
  100. var chart = echarts.init(document.getElementById('chart0'), null, {
  101. });
  102. chart.setOption({
  103. tooltip : {
  104. trigger: 'axis'
  105. },
  106. grid: {
  107. bottom: 150
  108. },
  109. dataZoom: {
  110. show: true,
  111. realtime: true,
  112. startValue: '2009-09-20 12:00',
  113. end: 100
  114. },
  115. xAxis : [
  116. {
  117. type : 'time',
  118. // splitNumber: 20,
  119. axisLabel: {
  120. rotate: 45,
  121. formatter: function (value) {
  122. return echarts.format.formatTime('yyyy-MM-dd hh:mm:ss', value);
  123. }
  124. }
  125. }
  126. ],
  127. yAxis : [
  128. {
  129. name: '流量(m^3/s)'
  130. }
  131. ],
  132. series : [
  133. {
  134. name: '流量',
  135. type: 'line',
  136. symbol: 'none',
  137. itemStyle: {normal: {areaStyle: {type: 'default'}}},
  138. data: rainfallData.flow.map(function (val, idx) {
  139. return [+(new Date(rainfallData.category[idx])), val];
  140. })
  141. }
  142. ]
  143. });
  144. })
  145. </script>
  146. <script>
  147. require([
  148. 'data/rainfall.json',
  149. 'echarts'
  150. // 'echarts/chart/line',
  151. // 'echarts/component/legend',
  152. // 'echarts/component/grid',
  153. // 'echarts/component/tooltip',
  154. // 'echarts/component/title',
  155. // 'echarts/component/dataZoom',
  156. // 'echarts/scale/Time'
  157. ], function (rainfallData, echarts) {
  158. var chart = echarts.init(document.getElementById('chart1'), null, {
  159. });
  160. chart.setOption({
  161. tooltip : {
  162. trigger: 'axis'
  163. },
  164. grid: {
  165. bottom: 150
  166. },
  167. dataZoom: {
  168. show: true,
  169. realtime: true,
  170. startValue: '2009-09-20 12:00',
  171. end: 100
  172. },
  173. xAxis : [
  174. {
  175. type : 'time',
  176. // splitNumber: 20,
  177. axisLabel: {
  178. showMaxLabel: true,
  179. showMinLabel: true,
  180. formatter: function (value) {
  181. return echarts.format.formatTime('yyyy-MM-dd hh:mm:ss', value);
  182. }
  183. }
  184. }
  185. ],
  186. yAxis : [
  187. {
  188. name: '流量(m^3/s)',
  189. position: 'right',
  190. axisLabel: {
  191. inside: true,
  192. showMaxLabel: false,
  193. formatter: '{value}\n'
  194. }
  195. }
  196. ],
  197. series : [
  198. {
  199. name: '流量',
  200. type: 'line',
  201. symbol: 'none',
  202. itemStyle: {normal: {areaStyle: {type: 'default'}}},
  203. data: rainfallData.flow.map(function (val, idx) {
  204. return [+(new Date(rainfallData.category[idx])), val];
  205. })
  206. }
  207. ]
  208. });
  209. })
  210. </script>
  211. </body>
  212. </html>