-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
draw_power_gauge.js
97 lines (94 loc) · 2.31 KB
/
draw_power_gauge.js
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
function drawPowerGauge(
moduleId,
tickPositioner,
config,
gaugeOptions,
translate
) {
const innerRadius = 60;
const radius = 100;
const midRadius =
radius - ((radius - innerRadius) * config.powerGaugeMarkSize) / 100;
const powerGauge = Highcharts.chart(
"power-" + moduleId,
Highcharts.merge(gaugeOptions, {
yAxis: {
min: 0,
max: config.powerGaugeMaxValue,
title: {
text: config.powerGaugeTitle || translate("POWER") + " (W)"
},
tickPositioner: tickPositioner,
labels: {
distance: 18,
formatter: function() {
return (this.value / 1000).toFixed(1);
}
}
},
credits: {
enabled: false
},
series: [
{
name: "Min1",
data: [{ y: 0, color: "#000" }],
zIndex: 12,
innerRadius: midRadius,
radius: radius - 1
},
{
name: "Min2",
data: [{ y: 0, color: config.powerGaugeMinTickColor }],
zIndex: 10,
innerRadius: midRadius,
radius: radius - 1
},
{
name: "Current",
data: [{ y: 0, color: "#00A" }],
innerRadius: innerRadius,
radius: midRadius,
dataLabels: {
enabled: true,
format:
'<div style="text-align:center">' +
'<span style="font-size:' +
config.gaugesValueFontSize +
'px">{y}</span><br/>' +
"</div>"
}
},
{
name: "Avg1",
data: [{ y: 0, color: "#000" }],
zIndex: 9,
innerRadius: midRadius - 1,
radius: radius - 1
},
{
name: "Avg2",
data: [{ y: 0, color: config.powerGaugeAvgTickColor }],
zIndex: 7,
innerRadius: midRadius,
radius: radius - 1
},
{
name: "Max1",
data: [{ y: 0, color: "#000" }],
zIndex: 5,
innerRadius: midRadius - 1,
radius: radius - 1
},
{
name: "Max2",
data: [{ y: 0, color: config.powerGaugeMaxTickColor }],
zIndex: 3,
innerRadius: midRadius,
radius: radius - 1
}
]
})
);
return powerGauge;
}