area.html 4.9 KB

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