华农3D项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
3.4 KiB

  1. <template>
  2. <div id="main3" :style="{height:height,width:width}" />
  3. </template>
  4. <script>
  5. import * as echarts from 'echarts'
  6. import resize from '@/utils/resizeMixins.js'
  7. export default {
  8. name: 'WaterPressureOutDoor',
  9. mixins: [resize],
  10. props: {
  11. outDoorData: {
  12. type: Number,
  13. require: true,
  14. default: function() {
  15. return 0
  16. }
  17. },
  18. width: {
  19. type: String,
  20. default: '100%'
  21. },
  22. height: {
  23. type: String,
  24. default: '100%'
  25. }
  26. },
  27. data() {
  28. return {
  29. chart: null,
  30. timeRePie: null
  31. }
  32. },
  33. watch: {
  34. 'outDoorData': {
  35. handler(val) {
  36. setTimeout(() => {
  37. this.initChart()
  38. }, 100)
  39. },
  40. immediate: true,
  41. deep: true
  42. }
  43. },
  44. mounted() {
  45. this.initChart()
  46. window.addEventListener('resize', this.__resizeHandler)
  47. },
  48. methods: {
  49. resetPieChartData() {
  50. clearInterval(this.timeRePie)
  51. this.timeRePie = setInterval(() => {
  52. if (!this.chart) {
  53. return
  54. }
  55. this.chart.clear()
  56. this.initChart()
  57. }, 8000)
  58. },
  59. initChart() {
  60. const chartDom = document.getElementById('main3')
  61. this.chart = echarts.init(chartDom)
  62. const option = {
  63. series: [
  64. {
  65. type: 'gauge',
  66. center: ['50%', '60%'],
  67. startAngle: 200,
  68. endAngle: -20,
  69. min: 0,
  70. max: 1.2,
  71. axisLine: {
  72. lineStyle: {
  73. width: 5,
  74. color: [
  75. [0.08, '#f65164'],
  76. [0.8, '#18b08f'],
  77. [1, '#c4c859']
  78. ]
  79. }
  80. },
  81. pointer: {
  82. icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
  83. length: '30%',
  84. width: 6,
  85. offsetCenter: [0, '-60%'],
  86. itemStyle: {
  87. color: '#F2F2F2'
  88. }
  89. },
  90. axisTick: {
  91. distance: -10,
  92. splitNumber: 1,
  93. lineStyle: {
  94. width: 1,
  95. color: '#fff'
  96. }
  97. },
  98. splitLine: {
  99. distance: -10,
  100. length: 2,
  101. lineStyle: {
  102. width: 1,
  103. color: '#FAC858'
  104. }
  105. },
  106. axisLabel: {
  107. distance: -15,
  108. color: '#fff',
  109. fontSize: 8
  110. },
  111. anchor: {
  112. show: false
  113. },
  114. title: {
  115. show: true,
  116. offsetCenter: [0, '50%'],
  117. fontSize: 14,
  118. color: '#fff'
  119. },
  120. detail: {
  121. valueAnimation: true,
  122. width: '60%',
  123. lineHeight: 5,
  124. borderRadius: 8,
  125. offsetCenter: [0, '-15%'],
  126. fontSize: 14,
  127. fontWeight: 'bolder',
  128. formatter: '{value} Mpa',
  129. color: 'auto'
  130. },
  131. data: [
  132. {
  133. value: this.outDoorData,
  134. name: '室外'
  135. }
  136. ]
  137. }
  138. ]
  139. }
  140. if (option) {
  141. this.chart.setOption(option)
  142. }
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped>
  148. </style>