YlgdChart.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: 10
  28. }
  29. },
  30. tooltip: {
  31. trigger: 'item'
  32. },
  33. grid:{
  34. left: '1',
  35. right: '1',
  36. bottom: '-11%',
  37. top: '20%',
  38. },
  39. series: [
  40. {
  41. name: this.$t('安全等级'),
  42. type: 'pie',
  43. radius: '50%',
  44. data: [
  45. {value: 1048, name: '1'},
  46. {value: 735, name: '2'},
  47. {value: 580, name: '3'},
  48. {value: 580, name: '4'},
  49. {value: 580, name: 'N/A'},
  50. ],
  51. emphasis: {
  52. itemStyle: {
  53. shadowBlur: 10,
  54. shadowOffsetX: 0,
  55. shadowColor: 'rgba(0, 0, 0, 0.5)'
  56. }
  57. }
  58. }
  59. ]
  60. }
  61. }
  62. },
  63. mounted() {
  64. this.initChart()
  65. },
  66. methods: {
  67. initChart() {
  68. // 基于准备好的dom,初始化echarts实例
  69. this.chart = this.echarts.init(document.getElementById('YlgdChart'))
  70. this.chart.setOption(this.ylrqSafeOption)
  71. },
  72. devYlgdSafeData(plantIds ,unitIds){
  73. let params = {
  74. 'plantIds': plantIds,
  75. 'unitIds': unitIds
  76. }
  77. devYlgdSafeData(params).then(response => {
  78. this.ylrqSafeOption.series[0].data[0].value = response.data.safeData[0]
  79. this.ylrqSafeOption.series[0].data[1].value= response.data.safeData[1]
  80. this.ylrqSafeOption.series[0].data[2].value= response.data.safeData[2]
  81. this.ylrqSafeOption.series[0].data[3].value= response.data.safeData[3]
  82. this.ylrqSafeOption.series[0].data[4].value= response.data.safeData[4]
  83. this.initChart()
  84. });
  85. }
  86. }
  87. }
  88. </script>