markArea.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. }
  13. </style>
  14. <div id="main"></div>
  15. <script>
  16. require([
  17. 'echarts',
  18. 'echarts/chart/line',
  19. 'echarts/component/legend',
  20. 'echarts/component/grid',
  21. 'echarts/component/tooltip',
  22. 'echarts/component/markArea'
  23. ], function (echarts) {
  24. var chart = echarts.init(document.getElementById('main'));
  25. var xAxisData = [];
  26. var data1 = [];
  27. var data2 = [];
  28. for (var i = 0; i < 10; i++) {
  29. xAxisData.push('类目' + i);
  30. data1.push(+Math.random().toFixed(2));
  31. data2.push(+Math.random().toFixed(2));
  32. }
  33. chart.setOption({
  34. legend: {
  35. data: ['line', 'line2']
  36. },
  37. tooltip: {
  38. trigger: 'axis',
  39. axisPointer: {
  40. type: 'line'
  41. }
  42. },
  43. xAxis: {
  44. data: xAxisData
  45. },
  46. yAxis: {},
  47. series: [{
  48. name: 'line',
  49. type: 'line',
  50. stack: 'all',
  51. symbolSize: 6,
  52. data: data1,
  53. markArea: {
  54. label: {
  55. normal: {
  56. // position: 'right'
  57. }
  58. },
  59. data: [
  60. [{
  61. name: 'x 3 - 5',
  62. xAxis: 3
  63. }, {
  64. xAxis: 5
  65. }]
  66. ]
  67. }
  68. }, {
  69. name: 'line2',
  70. type: 'line',
  71. stack: 'all',
  72. symbolSize: 6,
  73. data: data2,
  74. markArea: {
  75. label: {
  76. normal: {
  77. position: 'right'
  78. }
  79. },
  80. data: [
  81. [{
  82. name: 'y 0.5 - 0.7',
  83. yAxis: 0.5
  84. }, {
  85. yAxis: 0.7
  86. }]
  87. ]
  88. }
  89. }]
  90. });
  91. });
  92. </script>
  93. </body>
  94. </html>