zhaowei
23 小时以前 40616ee8255347c31235615d475321c4d42fdefe
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template>
  <div id="workshop-efficiency-average">
 
  </div>
</template>
 
<script>
  import * as echarts from 'echarts'
 
  export default {
    name: 'WorkshopEfficiencyAverageChart',
    components: {},
    props: {
      dataSource: {
        type: Object
      }
    },
    watch: {
      dataSource: {
        handler(value) {
          if (value) this.initChart()
        }
      }
    },
    data() {
      return {
        chartContainer: null
      }
    },
    mounted() {
      window.addEventListener('resize', this.handleWindowSizeChange)
    },
    methods: {
      initChart() {
        this.chartContainer = this.$echarts.init(document.getElementById('workshop-efficiency-average'))
        const option = {
          tooltip: {
            trigger: 'axis',
            fontSize: this.fontSize(0.26)
          },
          legend: {
            // data: ['开机率', '运行率', '切削率']
            top: '2%',
            right: '2%',
            data: [
              {
                name: '开机率',
                textStyle: {
                  color: '#eee',
                  fontSize: this.fontSize(0.16),
                  fontWeight: 'bold'
                }
              },
              {
                name: '利用率',
                textStyle: {
                  color: '#eee',
                  fontSize: this.fontSize(0.16),
                  fontWeight: 'bold'
                }
              },
              {
                name: '班次利用率',
                textStyle: {
                  color: '#eee',
                  fontSize: this.fontSize(0.16),
                  fontWeight: 'bold'
                }
              }
            ]
          },
          grid: {
            left: '3%',
            right: '3%',
            bottom: '3%',
            top: '15%',
            containLabel: true
          },
          xAxis: {
            type: 'category',
            axisTick: {
              show: true
            },
            boundaryGap: ['20%', '0%'],
            data: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
            axisLabel: {
              color: '#eee',
              fontSize: '80%',
              fontWeight: 'bold',
              interval: 0
            },
            axisLine: {
              lineStyle: {
                color: '#eee'
              }
            }
 
          },
          yAxis:
            [
              {
                type: 'value',
                axisTick: {
                  show: true
                },
                splitLine: {  //决定是否显示坐标中网格
                  show: true
                },
                min: 0.0,
                position: 'left',
                axisLabel: {
                  show: true,
                  interval: 'auto',
                  formatter: '{value}%',
                  textStyle: {
                    color: '#eee',
                    fontSize: '80%',
                    fontWeight: 'bold'
                  }
                },
                axisLine: {
                  lineStyle: {
                    color: ['white'],
                    width: 1,
                    show: true
                  }
                }
              }
            ],
          series: [
            {
              name: '开机率',
              type: 'line',
              symbol: 'circle',
              symbolSize: this.fontSize(0.12),
              // data: [38, 30, 44, 65, 23, 42],
              data: this.dataSource.openingRateList,
              itemStyle: {
                normal: {
                  color: '#2274ff',
                  fontSize: this.fontSize(0.12),
                  fontWeight: 'bold'
                }
              }
            },
            {
              name: '利用率',
              type: 'line',
              symbol: 'circle',
              symbolSize: this.fontSize(0.12),
              // data: [52, 44, 65, 59, 43, 21],
              data: this.dataSource.processingRateList,
              itemStyle: {
                normal: {
                  color: '#ff9e3c',
                  fontSize: this.fontSize(0.12),
                  fontWeight: 'bold'
                }
              }
            },
            {
              name: '班次利用率',
              type: 'line',
              // stack: '总量',
              symbol: 'circle',
              symbolSize: this.fontSize(0.12),
              // data: [60, 76, 59, 38, 82, 70],
              data: this.dataSource.shiftRateList,
              itemStyle: {
                normal: {
                  color: '#0aebff',
                  fontSize: this.fontSize(0.12),
                  fontWeight: 'bold'
                }
              }
            }
          ]
        }
        this.chartContainer.setOption(option, true)
      },
 
      //自适应字体方法封装
      fontSize(res) {
        var docEl = document.documentElement,
          clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
        if (!clientWidth) return
        var fontSize = 100 * (clientWidth / 1920)
        return res * fontSize
      },
 
      handleWindowSizeChange() {
        if (this.chartContainer) this.chartContainer.resize()
      }
    }
  }
</script>
 
<style scoped>
 
</style>