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
| import type { EChartsOption } from '@vben/plugins/echarts';
|
| /** 生产趋势图配置(多系列柱状/折线) */
| export function getProductionTrendChartOptions(
| dates: string[],
| batchCounts: number[],
| bagCodeCounts: number[],
| palletCounts: number[],
| inboundCounts: number[],
| ): EChartsOption {
| return {
| color: ['#409EFF', '#36cfc9', '#f59e0b', '#67c23a'],
| grid: { bottom: 40, left: 50, right: 30, top: 30 },
| legend: { bottom: 0, type: 'scroll' },
| series: [
| { barMaxWidth: 24, data: batchCounts, name: '新增批次', type: 'bar' },
| { barMaxWidth: 24, data: bagCodeCounts, name: '新增袋码', type: 'bar' },
| { barMaxWidth: 24, data: palletCounts, name: '新增托盘', type: 'bar' },
| { data: inboundCounts, name: '入库袋数', smooth: true, type: 'line' },
| ],
| tooltip: { trigger: 'axis' },
| xAxis: { axisTick: { show: false }, data: dates, type: 'category' },
| yAxis: { minInterval: 1, type: 'value' },
| };
| }
|
| /** 通用饼图/环形图配置 */
| export function getPieChartOptions(
| data: Array<{ name: string; value: number }>,
| ): EChartsOption {
| return {
| legend: { bottom: 0, type: 'scroll' },
| series: [
| {
| avoidLabelOverlap: true,
| data,
| emphasis: { label: { fontSize: 14, fontWeight: 'bold', show: true } },
| itemStyle: { borderColor: '#fff', borderRadius: 6, borderWidth: 2 },
| label: { formatter: '{b}\n{c}', show: true },
| radius: ['40%', '70%'],
| type: 'pie',
| },
| ],
| tooltip: { formatter: '{b}: {c} ({d}%)', trigger: 'item' },
| };
| }
|
| /** 通用柱状图配置 */
| export function getBarChartOptions(
| categories: string[],
| values: number[],
| name: string,
| color = '#409EFF',
| ): EChartsOption {
| return {
| grid: { bottom: 50, left: 60, right: 20, top: 30 },
| series: [
| {
| barMaxWidth: 36,
| data: values,
| itemStyle: { borderRadius: 4, color },
| name,
| type: 'bar',
| },
| ],
| tooltip: { axisPointer: { type: 'shadow' }, trigger: 'axis' },
| xAxis: {
| axisLabel: { interval: 0, rotate: categories.length > 6 ? 30 : 0 },
| axisTick: { show: false },
| data: categories,
| type: 'category',
| },
| yAxis: { minInterval: 1, type: 'value' },
| };
| }
|
| /** 通用折线图配置 */
| export function getLineChartOptions(
| dates: string[],
| values: number[],
| name: string,
| color = '#36cfc9',
| ): EChartsOption {
| return {
| grid: { bottom: 40, left: 60, right: 20, top: 30 },
| series: [
| { areaStyle: { opacity: 0.12 }, data: values, itemStyle: { color }, name, smooth: true, type: 'line' },
| ],
| tooltip: { trigger: 'axis' },
| xAxis: { axisTick: { show: false }, data: dates, type: 'category' },
| yAxis: { minInterval: 1, type: 'value' },
| };
| }
|
| /** 质检指标均值 + 合格率双系列柱状图配置 */
| export function getQualityIndicatorChartOptions(
| labels: string[],
| avgValues: number[],
| passRates: number[],
| ): EChartsOption {
| return {
| color: ['#409EFF', '#67c23a'],
| grid: { bottom: 40, left: 60, right: 60, top: 30 },
| legend: { bottom: 0, data: ['平均值', '合格率(%)'] },
| series: [
| { barMaxWidth: 30, data: avgValues, name: '平均值', type: 'bar' },
| { barMaxWidth: 30, data: passRates, name: '合格率(%)', type: 'bar' },
| ],
| tooltip: { trigger: 'axis' },
| xAxis: { axisTick: { show: false }, data: labels, type: 'category' },
| yAxis: [{ minInterval: 1, type: 'value' }],
| };
| }
|
|