area.html 5.0 KB

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