lineE.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <el-row >
  3. <div
  4. id="index7"
  5. style="position:absolute;
  6. top:-140px;
  7. left:-34px;
  8. width:125%;
  9. height:235px;"
  10. ></div>
  11. </el-row>
  12. </template>
  13. <script>
  14. import * as echarts from 'echarts';
  15. export default {
  16. props: ["resData"],
  17. data() {
  18. return {
  19. data:[]
  20. };
  21. },
  22. watch: {
  23. resData(val,old){
  24. this.data = val
  25. this.getData()
  26. }
  27. },
  28. methods: {
  29. getData() {
  30. let myChart = echarts.init(document.getElementById("index7"));
  31. let option = {
  32. color: [
  33. '#FF6868',
  34. '#E9CA7C',
  35. ],
  36. tooltip: {
  37. trigger: 'axis'
  38. },
  39. legend: {
  40. data: this.data[3]
  41. },
  42. grid: {
  43. left: '24%',
  44. containLabel: true
  45. },
  46. xAxis: {
  47. type: 'category',
  48. boundaryGap: false,
  49. data: this.data[0],
  50. axisTick: {
  51. alignWithLabel: true
  52. },
  53. axisLabel: {
  54. color: "#B9C4D8",
  55. },
  56. axisLine: {
  57. lineStyle: {
  58. color: "rgba(160,180,234,0.25)",
  59. },
  60. },
  61. },
  62. yAxis: {
  63. type: 'value',
  64. axisLabel: {
  65. color: "#B9C4D8",
  66. },
  67. splitLine: {
  68. show: true, // 不显示网格线
  69. lineStyle: {
  70. color: "#A0B4EA",
  71. },
  72. },
  73. },
  74. legend: {
  75. itemHeight: 8,
  76. itemWidth: 8,
  77. data: [
  78. {
  79. name: this.data[3][0],
  80. icon: 'circle',
  81. },
  82. {
  83. name: this.data[3][1],
  84. icon: 'circle',
  85. }
  86. ],
  87. top: '65%',
  88. left: 'left',
  89. textStyle: {
  90. color: "#FFF"
  91. }
  92. },
  93. series: [
  94. {
  95. name: this.data[3][0],
  96. type: 'line',
  97. stack: 'Total',
  98. smooth: true,
  99. symbol:'circle',
  100. symbolSize:[6,6],
  101. data: this.data[1]
  102. },
  103. {
  104. name: this.data[3][1],
  105. type: 'line',
  106. stack: 'Total',
  107. smooth: true,
  108. symbol:'circle',
  109. symbolSize:[6,6],
  110. data: this.data[2]
  111. }
  112. ]
  113. };
  114. myChart.setOption(option);
  115. option && myChart.setOption(option);
  116. setTimeout(function () {
  117. window.onresize = function () {
  118. myChart.resize();
  119. };
  120. }, 200);
  121. },
  122. },
  123. };
  124. </script>