gridSimple.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/config.js"></script>
  7. <script src="lib/facePrint.js"></script>
  8. </head>
  9. <body>
  10. <style>
  11. html, body, #main {
  12. width: 100%;
  13. height: 100%;
  14. }
  15. </style>
  16. <div id="info"></div>
  17. <div id="main"></div>
  18. <script>
  19. require([
  20. 'echarts'
  21. // 'echarts/chart/line',
  22. // 'echarts/chart/bar',
  23. // 'echarts/chart/pie',
  24. // 'echarts/component/legend',
  25. // 'echarts/component/gridSimple',
  26. // 'echarts/component/tooltip',
  27. // 'echarts/component/dataZoomInside'
  28. ], function (echarts) {
  29. var chart = echarts.init(document.getElementById('main'), null, {
  30. });
  31. var xAxisData = [];
  32. var data1 = [];
  33. var data2 = [];
  34. var data3 = [];
  35. for (var i = 0; i < 100; i++) {
  36. xAxisData.push('类目' + i);
  37. if (i < 5 && i > 1) {
  38. data1.push(0);
  39. }
  40. else {
  41. data1.push(+(Math.random() + 0.5).toFixed(3));
  42. }
  43. data2.push(+(Math.random() + 0.5).toFixed(3));
  44. data3.push(+(Math.random() + 0.5).toFixed(3));
  45. }
  46. var itemStyle = {
  47. normal: {
  48. borderColor: 'white',
  49. borderWidth: 3,
  50. // shadowBlur: 10,
  51. // shadowOffsetX: 0,
  52. // shadowOffsetY: 5,
  53. // shadowColor: 'rgba(0, 0, 0, 0.4)',
  54. lineStyle: {
  55. width: 1
  56. // shadowBlur: 10,
  57. // shadowOffsetX: 0,
  58. // shadowOffsetY: 5,
  59. // shadowColor: 'rgba(0, 0, 0, 0.4)'
  60. }
  61. }
  62. };
  63. chart.setOption({
  64. legend: {
  65. data: ['line', 'line2', 'line3']
  66. },
  67. visualMap: null, // 用于测试 option 中含有null的情况。
  68. tooltip: {
  69. trigger: 'axis',
  70. axisPointer: {
  71. type: 'line'
  72. }
  73. },
  74. xAxis: {
  75. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  76. data: xAxisData,
  77. boundaryGap: false,
  78. // inverse: true,
  79. splitArea: {
  80. show: false
  81. },
  82. splitLine: {
  83. show: false
  84. }
  85. },
  86. grid: {
  87. left: '10%',
  88. right: '10%'
  89. },
  90. yAxis: {
  91. splitArea: {
  92. show: true
  93. }
  94. },
  95. dataZoom: {
  96. type: 'inside',
  97. start: 10,
  98. end: 30
  99. },
  100. // animation: false,
  101. series: [null, // 用于测试 option 中含有null的情况。
  102. {
  103. name: 'line',
  104. type: 'line',
  105. stack: 'all',
  106. symbol: 'circle',
  107. symbolSize: 10,
  108. data: data1,
  109. itemStyle: itemStyle,
  110. step: 'end'
  111. }, {
  112. name: 'line2',
  113. type: 'pie',
  114. stack: 'all',
  115. symbol: 'circle',
  116. symbolSize: 10,
  117. data: echarts.util.map(data2, function (val) {
  118. return {name: val, value: val};
  119. }),
  120. itemStyle: itemStyle,
  121. step: 'end'
  122. }, {
  123. name: 'line3',
  124. type: 'bar',
  125. stack: 'all',
  126. symbol: 'triangle',
  127. symbolSize: 10,
  128. data: data3,
  129. itemStyle: itemStyle,
  130. step: 'end'
  131. }]
  132. });
  133. })
  134. </script>
  135. </body>
  136. </html>