YlgdChart.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div class="app-container-Ylrq">
  3. <div id="YlgdChart" :style="{height:height,width:width}"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import {devYlgdSafeData} from "@/api/sems/home";
  8. export default {
  9. props: {
  10. width: {
  11. type: String,
  12. default: '200px'
  13. },
  14. height: {
  15. type: String,
  16. default: '2.2rem'
  17. }
  18. },
  19. data() {
  20. return {
  21. chart: null,
  22. ylrqSafeOption: {
  23. title: {
  24. text: this.$t('压力管道安全状况等级'),
  25. left: 'center',
  26. textStyle: {
  27. fontSize: 12
  28. }
  29. },
  30. tooltip: {
  31. trigger: 'item'
  32. },
  33. series: [
  34. {
  35. name: this.$t('安全等级'),
  36. type: 'pie',
  37. radius: '50%',
  38. data: [
  39. {value: 1048, name: '1'},
  40. {value: 735, name: '2'},
  41. {value: 580, name: '3'},
  42. {value: 580, name: '4'},
  43. {value: 580, name: 'NA'},
  44. ],
  45. emphasis: {
  46. itemStyle: {
  47. shadowBlur: 10,
  48. shadowOffsetX: 0,
  49. shadowColor: 'rgba(0, 0, 0, 0.5)'
  50. }
  51. }
  52. }
  53. ]
  54. }
  55. }
  56. },
  57. mounted() {
  58. this.initChart()
  59. },
  60. methods: {
  61. initChart() {
  62. // 基于准备好的dom,初始化echarts实例
  63. this.chart = this.echarts.init(document.getElementById('YlgdChart'))
  64. this.chart.setOption(this.ylrqSafeOption)
  65. },
  66. devYlgdSafeData(plantIds ,unitIds){
  67. let params = {
  68. 'plantIds': plantIds,
  69. 'unitIds': unitIds
  70. }
  71. devYlgdSafeData(params).then(response => {
  72. this.ylrqSafeOption.series[0].data[0].value = response.data.safeData[0]
  73. this.ylrqSafeOption.series[0].data[1].value= response.data.safeData[1]
  74. this.ylrqSafeOption.series[0].data[2].value= response.data.safeData[2]
  75. this.ylrqSafeOption.series[0].data[3].value= response.data.safeData[3]
  76. this.ylrqSafeOption.series[0].data[4].value= response.data.safeData[4]
  77. this.initChart()
  78. });
  79. }
  80. }
  81. }
  82. </script>