multipleDust.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div class="multipleDust">
  3. <div class="multiple-box" ref="multiple"></div>
  4. </div>
  5. </template>
  6. <script setup lang="ts">
  7. import { ref, reactive, onMounted, nextTick } from 'vue'
  8. import * as echarts from 'echarts';
  9. //获取don元素节点
  10. let multiple = ref()
  11. function getOption() {
  12. nextTick(() => {
  13. let myChart = echarts.init(multiple.value);
  14. let option = {
  15. grid: {
  16. top: '8%',
  17. left: '5%',
  18. right: '5%',
  19. bottom: '8%',
  20. // containLabel: true
  21. },
  22. tooltip: {
  23. trigger: 'axis',
  24. axisPointer: {
  25. lineStyle: {
  26. color: {
  27. type: 'linear',
  28. x: 0,
  29. y: 0,
  30. x2: 0,
  31. y2: 1,
  32. colorStops: [{
  33. offset: 0,
  34. color: 'rgba(31, 179, 247,0)'
  35. }, {
  36. offset: 0.5,
  37. color: 'rgba(31, 179, 247,1)',
  38. }, {
  39. offset: 1,
  40. color: 'rgba(31, 179, 247,0)'
  41. }],
  42. global: false
  43. }
  44. },
  45. },
  46. },
  47. xAxis: [
  48. {
  49. type: 'category',
  50. boundaryGap: false,
  51. axisLine: {
  52. lineStyle: {
  53. color: 'rgba(100, 99, 99,.5)',
  54. type: 'dashed'
  55. },
  56. },
  57. // splitArea: {
  58. // show: true,
  59. // color: 'red',
  60. // lineStyle: {
  61. // color: 'red'
  62. // },
  63. // },
  64. axisLabel: {
  65. fontSize: 14,
  66. // margin: 10,
  67. textStyle: {
  68. color: '#b3b8cc',
  69. },
  70. },
  71. splitLine: {
  72. show: false,
  73. },
  74. axisTick: {
  75. show: false,
  76. },
  77. data: ['12-01', '12-02', '12-03', '12-04', '12-05', '12-06'],
  78. }
  79. ],
  80. yAxis: [{
  81. type: 'value',
  82. min: 0,
  83. // max: 140,
  84. // splitNumber: 4,
  85. splitLine: {
  86. show: true,
  87. lineStyle: {
  88. color: 'rgba(100, 99, 99,.5)',
  89. type: 'dashed'
  90. }
  91. },
  92. axisLine: {
  93. show: false,
  94. },
  95. axisLabel: {
  96. show: false,
  97. margin: 20,
  98. textStyle: {
  99. color: '#d1e6eb',
  100. },
  101. },
  102. axisTick: {
  103. show: false,
  104. },
  105. }],
  106. series: [
  107. {
  108. name: '粉尘浓度',
  109. type: 'line',
  110. smooth: true, //是否平滑
  111. showAllSymbol: true,
  112. // symbol: 'image://./static/images/guang-circle.png',
  113. symbol: 'circle',
  114. symbolSize: 10,
  115. lineStyle: {
  116. normal: {
  117. color: "#1fb3f7",
  118. },
  119. },
  120. label: {
  121. show: true,
  122. position: 'top',
  123. textStyle: {
  124. color: '#1fb3f7',
  125. }
  126. },
  127. itemStyle: {
  128. color: "#1fb3f7",
  129. borderColor: "#1fb3f7",
  130. borderWidth: 1,
  131. },
  132. tooltip: {
  133. show: false
  134. },
  135. areaStyle: {
  136. normal: {
  137. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  138. offset: 0,
  139. color: 'rgba(31, 179, 247,0.3)'
  140. },
  141. {
  142. offset: 1,
  143. color: 'rgba(31, 179, 247,0)'
  144. }
  145. ], false),
  146. shadowColor: 'rgba(31, 179, 247, 0.9)',
  147. shadowBlur: 20
  148. }
  149. },
  150. data: [502.84, 205.97, 332.79, 281.55, 398.35, 214.02,]
  151. },
  152. ]
  153. };
  154. myChart.setOption(option);
  155. window.onresize = function () {
  156. myChart.resize();
  157. };
  158. });
  159. }
  160. onMounted(() => {
  161. getOption()
  162. })
  163. </script>
  164. <style lang="less" scoped>
  165. .multipleDust {
  166. position: relative;
  167. width: 100%;
  168. height: 100%;
  169. .multiple-box {
  170. width: 100%;
  171. height: 100%;
  172. }
  173. }
  174. </style>