multipleDust.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. shadowColor: 'rgba(0, 0, 0, .3)',
  119. shadowBlur: 0,
  120. shadowOffsetY: 5,
  121. shadowOffsetX: 5,
  122. },
  123. },
  124. label: {
  125. show: true,
  126. position: 'top',
  127. textStyle: {
  128. color: '#1fb3f7',
  129. }
  130. },
  131. itemStyle: {
  132. color: "#1fb3f7",
  133. borderColor: "#fff",
  134. borderWidth: 3,
  135. shadowColor: 'rgba(0, 0, 0, .3)',
  136. shadowBlur: 0,
  137. shadowOffsetY: 2,
  138. shadowOffsetX: 2,
  139. },
  140. tooltip: {
  141. show: false
  142. },
  143. areaStyle: {
  144. normal: {
  145. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  146. offset: 0,
  147. color: 'rgba(31, 179, 247,0.3)'
  148. },
  149. {
  150. offset: 1,
  151. color: 'rgba(31, 179, 247,0)'
  152. }
  153. ], false),
  154. shadowColor: 'rgba(31, 179, 247, 0.9)',
  155. shadowBlur: 20
  156. }
  157. },
  158. data: [502.84, 205.97, 332.79, 281.55, 398.35, 214.02,]
  159. },
  160. ]
  161. };
  162. myChart.setOption(option);
  163. window.onresize = function () {
  164. myChart.resize();
  165. };
  166. });
  167. }
  168. onMounted(() => {
  169. getOption()
  170. })
  171. </script>
  172. <style lang="less" scoped>
  173. .multipleDust {
  174. position: relative;
  175. width: 100%;
  176. height: 100%;
  177. .multiple-box {
  178. width: 100%;
  179. height: 100%;
  180. }
  181. }
  182. </style>