bar-label-rotation.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. }
  15. #main {
  16. width: 1000px;
  17. background: #fff;
  18. }
  19. </style>
  20. <div id="main"></div>
  21. <script>
  22. require([
  23. 'echarts'
  24. // 'echarts/chart/bar',
  25. // 'echarts/component/legend',
  26. // 'echarts/component/grid',
  27. // 'echarts/component/tooltip'
  28. ], function (echarts) {
  29. var chart = echarts.init(document.getElementById('main'), null, {
  30. });
  31. var labelOption = {
  32. normal: {
  33. show: true,
  34. position: 'insideBottom',
  35. rotate: 90,
  36. textStyle: {
  37. align: 'left',
  38. verticalAlign: 'middle'
  39. }
  40. }
  41. };
  42. option = {
  43. color: ['#003366', '#006699', '#4cabce', '#e5323e'],
  44. tooltip: {
  45. trigger: 'axis',
  46. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  47. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  48. }
  49. },
  50. legend: {
  51. data:['A', 'B', 'C', 'D']
  52. },
  53. toolbox: {
  54. show: true,
  55. orient: 'vertical',
  56. left: 'right',
  57. top: 'center',
  58. feature: {
  59. mark: {show: true},
  60. dataView: {show: true, readOnly: false},
  61. magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  62. restore: {show: true},
  63. saveAsImage: {show: true}
  64. }
  65. },
  66. calculable: true,
  67. xAxis: [
  68. {
  69. type: 'category',
  70. axisTick: {show: false},
  71. data: ['2012', '2013', '2014', '2015', '2016']
  72. }
  73. ],
  74. yAxis: [
  75. {
  76. type: 'value'
  77. }
  78. ],
  79. series: [
  80. {
  81. name: 'A',
  82. type: 'bar',
  83. barGap: 0,
  84. label: labelOption,
  85. data: [320, 332, 301, 334, 390]
  86. },
  87. {
  88. name: 'B',
  89. type: 'bar',
  90. label: labelOption,
  91. data: [220, 182, 191, 234, 290]
  92. },
  93. {
  94. name: 'C',
  95. type: 'bar',
  96. label: labelOption,
  97. data: [150, 232, 201, 154, 190]
  98. },
  99. {
  100. name: 'D',
  101. type: 'bar',
  102. label: labelOption,
  103. data: [98, 77, 101, 99, 30]
  104. }
  105. ]
  106. }
  107. chart.setOption(option);
  108. });
  109. </script>
  110. </body>
  111. </html>