markArea.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/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. itemStyle: {
  55. // normal: {
  56. // color: 'red'
  57. // },
  58. emphasis: {
  59. color: 'yellow'
  60. }
  61. },
  62. label: {
  63. normal: {
  64. // position: 'right'
  65. }
  66. },
  67. data: [
  68. [{
  69. name: 'x 3 - 5',
  70. xAxis: 3
  71. }, {
  72. xAxis: 5
  73. }]
  74. ]
  75. }
  76. }, {
  77. name: 'line2',
  78. type: 'line',
  79. stack: 'all',
  80. symbolSize: 6,
  81. data: data2,
  82. markArea: {
  83. label: {
  84. normal: {
  85. position: 'right'
  86. }
  87. },
  88. data: [
  89. [{
  90. name: 'y 0.5 - 0.7',
  91. yAxis: 0.5
  92. }, {
  93. yAxis: 0.7
  94. }]
  95. ]
  96. }
  97. }]
  98. });
  99. });
  100. </script>
  101. </body>
  102. </html>