line.html 4.6 KB

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