theme.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. </head>
  7. <body>
  8. <style>
  9. html, body, #main {
  10. width: 100%;
  11. height: 100%;
  12. margin: 0;
  13. }
  14. #main {
  15. width: 1000px;
  16. background: #fff;
  17. }
  18. </style>
  19. <div id="main"></div>
  20. <script>
  21. require([
  22. 'echarts',
  23. 'theme/dark',
  24. 'echarts/chart/bar',
  25. 'echarts/component/legend',
  26. 'echarts/component/grid',
  27. 'echarts/component/tooltip'
  28. ], function (echarts, theme) {
  29. var chart = echarts.init(document.getElementById('main'), 'dark');
  30. var xAxisData = [];
  31. var data1 = [];
  32. var data2 = [];
  33. var data3 = [];
  34. var data4 = [];
  35. for (var i = 0; i < 10; i++) {
  36. xAxisData.push('类目' + i);
  37. data1.push((Math.random() * 5).toFixed(2));
  38. data2.push(-Math.random().toFixed(2));
  39. data3.push((Math.random() + 0.5).toFixed(2));
  40. data4.push((Math.random() + 0.3).toFixed(2));
  41. }
  42. var itemStyle = {
  43. normal: {
  44. label: {
  45. show: true,
  46. position: 'outside'
  47. }
  48. },
  49. emphasis: {
  50. shadowBlur: 10,
  51. shadowOffsetX: 0,
  52. shadowOffsetY: 0,
  53. shadowColor: 'rgba(0,0,0,0.5)'
  54. }
  55. };
  56. console.profile('setOption');
  57. chart.setOption({
  58. legend: {
  59. data: [{
  60. name: 'bar'
  61. }, 'bar2', 'bar3', 'bar4'],
  62. selected: {
  63. // 'bar': false
  64. },
  65. orient: 'vertical',
  66. left: 'right',
  67. top: 'bottom',
  68. align: 'right'
  69. },
  70. tooltip: {},
  71. xAxis: {
  72. data: xAxisData,
  73. axisLine: {
  74. onZero: true
  75. },
  76. splitLine: {
  77. show: false
  78. },
  79. splitArea: {
  80. show: false
  81. }
  82. },
  83. yAxis: {
  84. inverse: true,
  85. splitArea: {
  86. show: false
  87. }
  88. },
  89. series: [{
  90. name: 'bar',
  91. type: 'bar',
  92. stack: 'one',
  93. itemStyle: itemStyle,
  94. data: data1
  95. }, {
  96. name: 'bar2',
  97. type: 'bar',
  98. stack: 'one',
  99. itemStyle: itemStyle,
  100. data: data2
  101. }, {
  102. name: 'bar3',
  103. type: 'bar',
  104. stack: 'two',
  105. itemStyle: itemStyle,
  106. data: data3
  107. }, {
  108. name: 'bar4',
  109. type: 'bar',
  110. stack: 'two',
  111. itemStyle: itemStyle,
  112. data: data4
  113. }]
  114. });
  115. console.profileEnd('setOption');
  116. })
  117. </script>
  118. </body>
  119. </html>