Lius
2024-12-13 b4a53d0cf96ee1520a942d092762fabaf9471e5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
  <div class="comparative_pie" style="width: 100%;height: 600px;display: flex;overflow: scroll">
    <div id="compAnalPie1" style="flex: 1;"></div>
    <div id="compAnalPie2" style="flex: 1;"></div>
  </div>
</template>
 
<script>
  import * as echarts from 'echarts'
  export default {
    name: 'conparativeAnalysisPie',
    props:{ dataList:''},
    data(){
      return{
        closeRate:0,
        openRate:0,
        usedRate:0,
        waitRate:0,
        RateList:[]
      }
    },
    created(){
 
    },
    watch:{
      dataList(val){
        this.RateList = val
        console.log(val)
        this.drawTu()
      },
    },
    mounted() {
      this.drawTu()
    },
    methods:{
      drawTu(){
       let pieCompChart1 = this.$echarts.init(document.getElementById('compAnalPie1'),'macarons');
       let pieCompChart2 = this.$echarts.init(document.getElementById('compAnalPie2'),'macarons');
       let pieCompChartOption1 = {
          title: {
            x: 'center',
            subtext: '开机效率'
          },
          tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
          },
          legend: {
            orient: 'vertical',
            x: 'left',
            y: 'bottom',
            data: ['开机率', '关机率']
          },
          calculable: true,
          series: [{
            name: '开机效率',
            type: 'pie',
            radius: '70%',
            center: ['55%', '55%'],
            itemStyle: {
              normal: {
                color: function (params) {
                  var colorList = ['#4169E1', '#A8A8A8'];
                  return colorList[params.dataIndex]
                },
                label: {
                  show: true,
                  position: 'top',
                  formatter: '{b}\n{c}'
                }
              }
            },
            data: [{value: 0, name: '开机率'},
              {value: 0, name: '关机率'}]
          }]
        };
       let pieCompChartOption2 = {
          title: {
            x: 'center',
            subtext: '运行效率'
          },
          tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
          },
          legend: {
            orient: 'vertical',
            x: 'left',
            y: 'bottom',
            data: ['加工率', '待机率', '关机率']
          },
          calculable: true,
          series: [{
            name: '运行效率',
            type: 'pie',
            radius: '70%',
            center: ['55%', '55%'],
            itemStyle: {
              normal: {
                color: function (params) {
                  var colorList = ['#00ee00', '#FCCE10', '#A8A8A8'];
                  return colorList[params.dataIndex]
                },
                label: {
                  show: true,
                  position: 'top',
                  formatter: '{b}\n{c}'
                }
              }
            },
            data: [{value: 0, name: '加工率'},
              {value: 0, name: '待机率'},
              {value: 0, name: '关机率'}]
          }]
        };
        if(this.RateList != null){
          this.closeRate =[]
          this.openRate =[]
          this.usedRate = []
          this.waitRate = []
          if(this.RateList.length>0){
            this.closeRate=this.RateList[0].closeRate
            this.openRate=this.RateList[0].openRate
            this.usedRate=this.RateList[0].processRate
            this.waitRate=this.RateList[0].waitRate
            pieCompChartOption1.series[0].data = [{value:(this.openRate * 100).toFixed(2), name:'开机率'},{value:(this.closeRate * 100).toFixed(2), name:'关机率'}];
            pieCompChartOption2.series[0].data = [{value:(this.usedRate * 100).toFixed(2), name:'加工率'},{value:(this.waitRate * 100).toFixed(2), name:'待机率'},{value:(this.closeRate * 100).toFixed(2), name:'关机率'}];
            pieCompChart1.setOption(pieCompChartOption1);
            pieCompChart2.setOption(pieCompChartOption2);
          }else{
            pieCompChart1.setOption(pieCompChartOption1);
            pieCompChart2.setOption(pieCompChartOption2);
          }
 
        }else{
          pieCompChart1.setOption(pieCompChartOption1);
          pieCompChart2.setOption(pieCompChartOption2);
        }
 
        pieCompChart1.setOption(pieCompChartOption1);
        pieCompChart2.setOption(pieCompChartOption2);
        window.addEventListener('resize', function() {
          pieCompChart1.resize()
          pieCompChart2.resize()
        })
      }
    }
  }
</script>
 
<style scoped>
 
</style>