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
| import type { EChartsOption } from '@vben/plugins/echarts';
|
| /** 农业主题:翠绿主色(对齐登录页,浅色玻璃版) */
| export const AGRI_GREEN = '#10b981';
| export const AGRI_GREEN_LIGHT = '#34d399';
| export const AGRI_GREEN_PALE = '#6ee7b7';
| export const AGRI_TEXT = '#134e4a';
| export const AGRI_TEXT_MUTED = 'rgba(15, 78, 60, 0.62)';
| export const AGRI_SPLIT = 'rgba(16, 185, 129, 0.18)';
|
| /** 深底通用文本样式 */
| const darkText: NonNullable<EChartsOption['textStyle']> = { color: AGRI_TEXT };
|
| /** 袋码生成趋势柱状图配置 */
| export function getBagCodeTrendChartOptions(
| dates: string[],
| counts: number[],
| ): EChartsOption {
| return {
| grid: { bottom: 40, left: 50, right: 20, top: 20 },
| legend: { bottom: 0, data: ['袋码生成量'], textStyle: { color: AGRI_TEXT_MUTED } },
| series: [
| {
| barMaxWidth: 32,
| data: counts,
| itemStyle: { borderRadius: 4, color: AGRI_GREEN },
| name: '袋码生成量',
| type: 'bar',
| },
| ],
| textStyle: darkText,
| tooltip: { axisPointer: { type: 'shadow' }, trigger: 'axis' },
| xAxis: {
| axisLine: { lineStyle: { color: AGRI_SPLIT } },
| axisLabel: { color: AGRI_TEXT_MUTED },
| axisTick: { show: false },
| data: dates,
| type: 'category',
| },
| yAxis: {
| minInterval: 1,
| splitLine: { lineStyle: { color: AGRI_SPLIT } },
| axisLabel: { color: AGRI_TEXT_MUTED },
| type: 'value',
| },
| };
| }
|
| /** 状态分布环形图配置 */
| export function getStatusChartOptions(
| data: Array<{ itemStyle: { color: string }; name: string; value: number }>,
| ): EChartsOption {
| return {
| legend: { bottom: 0, textStyle: { color: AGRI_TEXT_MUTED }, type: 'scroll' },
| series: [
| {
| avoidLabelOverlap: true,
| data,
| emphasis: { label: { fontSize: 14, fontWeight: 'bold', show: true } },
| itemStyle: { borderColor: '#ffffff', borderRadius: 6, borderWidth: 2 },
| label: { color: AGRI_TEXT, formatter: '{b}\n{c}', show: true },
| radius: ['40%', '70%'],
| type: 'pie',
| },
| ],
| textStyle: darkText,
| tooltip: { formatter: '{b}: {c} ({d}%)', trigger: 'item' },
| };
| }
|
| /** 消费者扫码地区分布横向柱状图配置 */
| export function getRegionBarChartOptions(
| data: Array<{ name: string; count: number }>,
| ): EChartsOption {
| const sorted = [...data].sort((a, b) => b.count - a.count);
| return {
| grid: { bottom: 20, left: 16, right: 40, top: 20, containLabel: true },
| series: [
| {
| barMaxWidth: 20,
| data: sorted.map((d) => d.count),
| itemStyle: { borderRadius: 4, color: AGRI_GREEN },
| name: '扫码次数',
| type: 'bar',
| },
| ],
| textStyle: darkText,
| tooltip: { axisPointer: { type: 'shadow' }, trigger: 'axis' },
| xAxis: {
| axisLabel: { color: AGRI_TEXT_MUTED },
| axisLine: { lineStyle: { color: AGRI_SPLIT } },
| splitLine: { lineStyle: { color: AGRI_SPLIT } },
| type: 'value',
| },
| yAxis: {
| axisLabel: { color: AGRI_TEXT },
| axisLine: { lineStyle: { color: AGRI_SPLIT } },
| data: sorted.map((d) => d.name),
| type: 'category',
| inverse: true,
| },
| };
| }
|
|