index.config.ts
2.27 KB
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
import { FormFieldsEnum, defaultFlowmetmerColorConfig } from '../CircularFlowMeter/form.config'
import { isLightboxMode } from '@/utils/env'
import type { FlowMeterColorItemType } from '@/api/node/model'
export function getSetValue(value: number) {
return [
value / 100,
(value - 10) / 100,
(value - 20) / 100,
]
}
export const setOption = (value: number = 40, circularFlowMeterOption: FlowMeterColorItemType[] = defaultFlowmetmerColorConfig) => {
const colorMap = (isLightboxMode() ? circularFlowMeterOption : defaultFlowmetmerColorConfig).reduce((prev, next) => ({ ...prev, [next.key]: next.value }), {} as Record<FormFieldsEnum, string>)
return {
series: [
{
type: 'liquidFill',
radius: '90%',
shape: 'rect', // 设置水球图形状
data: getSetValue(value),
color: [colorMap[FormFieldsEnum.COLOR_FIRST], colorMap[FormFieldsEnum.COLOR_SECOND], colorMap[FormFieldsEnum.COLOR_THIRD]],
itemStyle: {
opacity: 0.6,
},
backgroundStyle: {
borderWidth: 1,
color: colorMap[FormFieldsEnum.BACKGROUND], // 这里设置背景色
},
emphasis: {
itemStyle: {
opacity: 0.9,
},
},
label: {
color: '#fff',
insideColor: '#f7e8c1',
left: '50%',
top: '40%',
textAlign: 'center',
fontSize: 20,
fontWeight: 600,
textBorderColor: 'rgba(0, 0, 0, 0)',
textShadowColor: '#000',
textShadowBlur: 0,
textShadowOffsetX: 0,
textShadowOffsetY: 1,
},
outline: {
show: true,
borderDistance: 1,
itemStyle: {
borderWidth: 0,
color: {
type: 'linear',
x: 0,
y: 0,
x2: 1,
y2: 0,
colorStops: [
{
offset: 0,
color: '#0b2355', // 这里设置水球外边框 0% 处的颜色
},
{
offset: 1,
color: '#195b9d', // 这里设置水球外边框 100% 处的颜色
},
],
global: false,
},
},
},
},
],
}
}