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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
| <template>
| <div class="chart-container" :id="chartContainerId"></div>
| </template>
|
| <script>
| import * as echarts from 'echarts'
|
| export default {
| name: 'DayUtilizationRateTrend',
| components: {},
| props: {
| toDecimal2NoZero: {
| type: Function
| }
| },
| data() {
| return {
| chartContainer: null,
| chartContainerId: 'left-col-chart4'
| }
| },
| mounted() {
| this.getChartDataByApi()
| window.addEventListener('resize', this.handleWindowResize)
| },
| beforeDestroy() {
| window.removeEventListener('resize', this.handleWindowResize)
| },
| methods: {
| getChartDataByApi() {
| this.chartContainer = this.$echarts.init(document.getElementById(this.chartContainerId))
| this.initChart()
| },
|
| initChart() {
| const data = [
| {
| 'number': 'A_1',
| 'name': '1-D特种工艺',
| 'count': 0.4452,
| 'planCount': null,
| 'rateCount': null
| },
| {
| 'number': 'A_2',
| 'name': '2-D整体机匣',
| 'count': 0.7642,
| 'planCount': null,
| 'rateCount': null
| },
| {
| 'number': 'A_3',
| 'name': '3-D燃烧室机匣',
| 'count': 0.4523,
| 'planCount': null,
| 'rateCount': null
| },
| {
| 'number': 'A_4',
| 'name': '4-D焊接机匣工段',
| 'count': 0.6987,
| 'planCount': null,
| 'rateCount': null
| },
| {
| 'number': 'A_5',
| 'name': '5-D CRIC单元',
| 'count': 0.8924,
| 'planCount': null,
| 'rateCount': null
| },
| ]
| const xAxisData = []
| const seriesData = []
| const option = {
| tooltip: {
| show: true,
| trigger: 'item',
| formatter: params => `${params.name}:${params.value}%`
| },
| legend: {
| show: false,
| data: [],
| itemWidth: 12,
| itemHeight: 12,
| textStyle: { //图例文字的样式
| //fontSize:14,
| color: '#fff'
| }
| },
| grid: {
| left: '3%',
| right: '4%',
| bottom: '-3%',
| top: '5%',
| containLabel: true
| },
| xAxis: [
| {
| type: 'category',
| data: [],
| axisLine: {
| lineStyle: {
| color: '#fff'
| }
| },
| axisLabel: {
| color: '#fff',
| rotate: 45,
| fontSize: '55%'
| }
| }
| ],
| yAxis: [
| {
| type: 'value',
| data: [],
| axisLine: {
| show: true,
| lineStyle: {
| color: '#fff'
| }
| },
| axisLabel: {
| formatter: '{value} %',
| color: '#fff',
| fontSize: '70%'
| },
| splitLine: {
| lineStyle: {
| color: '#626262'
| }
| }
| }
| ],
| dataZoom: [
| {
| type: 'inside',
| show: true,
| xAxisIndex: [0],
| start: 0,
| end: 100
| }
| ],
| series: [
| {
| name: '利用率',
| type: 'bar',
| barWidth: '50%',//柱图宽度
| data: [],
| label: {
| show: true,
| position: 'inside',
| padding: [1, 2],
| fontSize: '60%',
| color: '#fff',
| formatter: '{c}%',
| backgroundColor: '#4fb327',
| shadowColor: '#153e04',
| shadowBlur: 5,
| shadowOffsetX: 3,
| shadowOffsetY: 5,
| borderRadius: 5
| },
| //barCategoryGap:'180%',
| itemStyle: {
| normal: {
| barBorderRadius: '',
| color: function(params) {
| const colorList = [
| //1-D特种工艺单元
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#9cc4f6' },
| { offset: 1, color: '#538dd6' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#ffffa2' },
| { offset: 1, color: '#ffff01' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#97fcc5' },
| { offset: 1, color: '#0bae8d' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#ffbc85' },
| { offset: 1, color: '#e26c0a' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#fb78ba' },
| { offset: 1, color: '#8f0149' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| //环件单元
| { offset: 0, color: '#d297ff' },
| { offset: 1, color: '#7030a0' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#ffe491' },
| { offset: 1, color: '#8f6c00' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#ffb6b9' },
| { offset: 1, color: '#fd4c53' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#92cbba' },
| { offset: 1, color: '#18a387' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#ff5b62' },
| { offset: 1, color: '#a02100' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#b5d5e3' },
| { offset: 1, color: '#1b8bd0' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| //中小机匣单元
| { offset: 0, color: '#ebd3ff' },
| { offset: 1, color: '#e889ff' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#D69123' },
| { offset: 1, color: '#a16900' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| //低压导向
| { offset: 0, color: '#d588c8' },
| { offset: 1, color: '#9545AE' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| //低压叶片 1 4
| { offset: 0, color: '#97abd6' },
| { offset: 1, color: '#6268b2' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#d7dab2' },
| { offset: 1, color: '#b8aa15' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#e9c9b0' },
| { offset: 1, color: '#D9646A' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#a4e3d6' },
| { offset: 1, color: '#01A55E' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
|
| { offset: 0, color: '#2052b1' },
| { offset: 1, color: '#002b73' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| //盘件单元
| { offset: 0, color: '#3e71e2' },
| { offset: 1, color: '#0042c8' }
| ]
| ), new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| //结构件单元
| { offset: 0, color: '#99d6cf' },
| { offset: 1, color: '#21bf90' }
| ]
| )
| , new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| // 7-D
| { offset: 0, color: '#99d6cf' },
| { offset: 1, color: '#0ad0bb' }
| ]
| )
| , new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#FF9297' },
| { offset: 1, color: '#FF9297' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#fb78ba' },
| { offset: 1, color: '#ff77dc' }
| ]
| ),
| //一厂
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#9cc4f6' },
| { offset: 1, color: '#538dd6' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#ffffa2' },
| { offset: 1, color: '#ffff01' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#0bae8d' },
| { offset: 1, color: '#0bae8d' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#ffbc85' },
| { offset: 1, color: '#e26c0a' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#97abd6' },
| { offset: 1, color: '#842cb2' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#99d6cf' },
| { offset: 1, color: '#0ad0bb' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#FF9297' },
| { offset: 1, color: '#FF9297' }
| ]
| ),
| new echarts.graphic.LinearGradient(
| 0, 0, 1, 0,
| [
| { offset: 0, color: '#fb78ba' },
| { offset: 1, color: '#ff77dc' }
| ]
| )
| ]
| if (params.name == '1-D特种工艺' || params.name == '压气机一' || params.name == '1-D特种工艺单元') {
| return colorList[24]
| }
| if (params.name == '2-D整体机匣' || params.name == '2-D整体机匣单元') {
| return colorList[25]
| }
| if (params.name == '3-D燃烧室机匣' || params.name == '燃烧室机匣' || params.name == '3-D压气机机匣单元' || params.name == '3-D压气机机匣') {
| return colorList[26]
| }
| if (params.name == '4-D焊接机匣工段' || params.name == '三工段' || params.name == '支架小环件单元' || params.name == '4-D焊接机匣单元') {
| return colorList[27]
| }
| if (params.name == '5-D CRIC单元' || params.name == '10-D部件装配单元') {
| return colorList[4]
| }
| if (params.name == '6-D风扇单元' || params.name == '6-D风扇机匣单元') {
| return colorList[28]
| }
| if (params.name == '7-D涡轮机匣' || params.name == '7-D涡轮机匣单元') {
| return colorList[29]
| }
| if (params.name == '8-D科研工段' || params.name == '科研工段' || params.name == '8-D科研单元') {
| return colorList[30]
| }
| if (params.name == '10-D部件装配' || params.name == '10-D部件装配单元') {
| return colorList[31]
| }
| if (params.name == 'JD-2军品机加' || params.name == '军品机加工段' || params.name == '四工段') {
| return colorList[8]
| }
| if (params.name == '10-D生产室' || params.name == 'IGV叶片') {
| return colorList[9]
| }
|
| if (params.name == '五工段') {
| return colorList[10]
| }
| if (params.name == '六工段' || params.name == '中小机匣单元') {
| return colorList[11]
| }
| if (params.name == '涡轮叶片') {
| return colorList[12]
| }
| if (params.name == '低压导向') {
| return colorList[13]
| }
| if (params.name == '低压叶片') {
| return colorList[14]
| }
| if (params.name == '导向叶片') {
| return colorList[15]
| }
| if (params.name == '压气机二') {
| return colorList[16]
| }
| if (params.name == '整流一') {
| return colorList[17]
| }
| if (params.name == '整流二') {
| return colorList[19]
| }
| if (params.name == '一工段' || params.name == '盘件单元') {
| return colorList[19]
| }
| if (params.name == '二工段' || params.name == '结构件单元') {
| return colorList[20]
| }
| if (params.name == '七工段' || params.name == '环件单元') {
| return colorList[5]
| }
| // build a color map as your need.
|
| //return colorList[params.dataIndex]
| }
| },
| emphasis: {
| barBorderRadius: 13,
| shadowBlur: 18,
| shadowColor: 'rgba(218,170, 58, 0.8)'
| }
| }
| }
| ]
| }
| data.forEach(item => {
| xAxisData.push(item.name == null ? '' : item.name)
| seriesData.push({
| value: this.toDecimal2NoZero(((item.count == null ? '' : item.count) * 100) > 100 ? 100 : (((item.count == null ? '' : item.count) * 100))),
| hostType: (item.number == null ? '' : item.number)
| })
| })
| option.xAxis[0].data = xAxisData
| option.series[0].data = seriesData
| this.chartContainer.setOption(option, true)
| },
|
| /**
| * 窗口尺寸变化时触发
| * 调整图表尺寸以适应分辨率
| */
| handleWindowResize() {
| if (this.chartContainer) this.chartContainer.resize()
| }
| }
| }
| </script>
|
|