ptCountChart.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div id="ptCountChart" :style="{height:height,width:width}"/>
  3. </template>
  4. <script>
  5. import {xlcdByPoint} from "@/api/statistics/statistics";
  6. export default {
  7. props: {
  8. queryParams: {
  9. type: Object,
  10. default() {
  11. return {};
  12. }
  13. },
  14. width: {
  15. type: String,
  16. default: '100%'
  17. },
  18. height: {
  19. type: String,
  20. default: '490px'
  21. },
  22. },
  23. data() {
  24. return {
  25. chart: null,
  26. dataList:[],
  27. option: {
  28. title: {
  29. text: '按密封点类型统计',
  30. textStyle: {color: '#666', fontSize: 14, fontWeight: 'normal'},
  31. padding: [5, 5, 5, 5],
  32. },
  33. legend: {
  34. orient: 'horizontal',
  35. top: 0,
  36. itemWidth: 30,
  37. itemHeight: 12,
  38. data: ['严重泄漏', '一般泄露', '未泄露']
  39. },
  40. grid: {left: 10, top: 50, bottom: 20, right: 20, containLabel: true},
  41. xAxis: {
  42. type: 'value',
  43. axisLine: {show: true, lineStyle: {color: '#ccc'}},
  44. axisLabel: {color: '#999'},
  45. splitLine: {lineStyle: {color: ['#CEEDFF'], type: [5, 8], dashOffset: 3}},
  46. },
  47. yAxis: {
  48. type: 'category',
  49. data: [],
  50. axisLine: {lineStyle: {color: '#ccc'}},
  51. axisTick: {length: 3},
  52. axisLabel: {color: '#999'},
  53. },
  54. tooltip: {
  55. trigger: 'axis',
  56. axisPointer: {type: 'shadow'},
  57. textStyle: {color: '#424242'},
  58. renderMode: 'html',
  59. className: 'tooltip',
  60. order: 'seriesDesc',
  61. },
  62. toolbox: {
  63. show: true,
  64. feature: {
  65. mark: {show: true},
  66. restore: {show: true},
  67. saveAsImage: {show: true}
  68. }
  69. },
  70. series: [
  71. {
  72. name: '严重泄漏',
  73. type: 'bar',
  74. stack: 'total', // ! 多条数据总计 => 堆叠
  75. barWidth: 30,
  76. color: '#f5804d',
  77. itemStyle: {borderRadius: [5, 5, 5, 5]},
  78. data: [],
  79. },
  80. {
  81. name: '一般泄露',
  82. type: 'bar',
  83. stack: 'total', // ! 多条数据总计 => 堆叠
  84. barWidth: 30,
  85. color: '#FFC53D',
  86. itemStyle: {borderRadius: [5, 5, 5, 5]},
  87. data: [],
  88. },
  89. {
  90. name: '未泄露',
  91. type: 'bar',
  92. stack: 'total', // ! 多条数据总计 => 堆叠
  93. barWidth: 30,
  94. color: '#8bd46e',
  95. itemStyle: {borderRadius: [5, 5, 5, 5]},
  96. data: [],
  97. },
  98. ],
  99. }
  100. }
  101. },
  102. mounted() {
  103. this.$nextTick(() => {
  104. xlcdByPoint(this.queryParams).then(response => {
  105. this.dataList=response.data;
  106. this.dataList.forEach(item => {
  107. this.option.series[0].data.push(item.yzxlCount == null ? 0 : item.yzxlCount);
  108. this.option.series[1].data.push(item.ybxlCount == null ? 0 : item.ybxlCount);
  109. this.option.series[2].data.push(item.wxlCount == null ? 0 : item.wxlCount);
  110. this.option.yAxis.data.push(item.pointType);
  111. })
  112. this.initChart();
  113. })
  114. })
  115. },
  116. methods: {
  117. initChart() {
  118. // 基于准备好的dom,初始化echarts实例
  119. this.chart = this.echarts.init(document.getElementById('ptCountChart'))
  120. this.chart.setOption(this.option)
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. </style>