-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
draw_voltage_gauge.js
93 lines (90 loc) · 2.55 KB
/
draw_voltage_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
function drawVoltageGauge(moduleId, config, gaugeOptions, is3phase, translate) {
const innerRadius3 = 60;
const radius = 100;
const innerRadius2 = innerRadius3 + (radius - innerRadius3) / 3;
const innerRadius1 = is3phase
? radius - (radius - innerRadius3) / 3
: innerRadius3;
const labelFontSize = is3phase
? config.gaugesValueFontSize3phase
: config.gaugesValueFontSize;
const voltageGauge = Highcharts.chart(
"voltage-" + moduleId,
Highcharts.merge(gaugeOptions, {
yAxis: {
min: config.voltageGaugeMinValue,
max: config.voltageGaugeMaxValue,
tickPositions: [
config.voltageGaugeMinValue,
config.voltageGaugeNominalValue,
config.voltageGaugeMaxValue
],
title: {
text: config.voltageGaugeTitle || translate("VOLTAGE") + " (V)"
},
labels: {
distance: 18,
formatter: function() {
return this.value.toFixed(0);
}
}
},
credits: {
enabled: false
},
series: [
{
name: "Phase1",
data: [{ y: 0, color: "#000" }],
innerRadius: innerRadius1,
radius: radius - 1,
dataLabels: {
enabled: true,
x: is3phase ? -38 - config.gaugesValueDistanceAdjustment : 0,
format:
'<div style="text-align:center">' +
'<span style="font-size:' +
labelFontSize +
'px">{y}</span><br/>' +
"</div>"
}
},
{
name: "Phase2",
data: [{ y: 0, color: "#000" }],
innerRadius: innerRadius2,
radius: innerRadius1 - 1,
visible: is3phase,
dataLabels: {
enabled: true,
x: 0,
format:
'<div style="text-align:center">' +
'<span style="font-size:' +
labelFontSize +
'px">{y}</span><br/>' +
"</div>"
}
},
{
name: "Phase3",
data: [{ y: 0, color: "#000" }],
innerRadius: innerRadius3,
radius: innerRadius2 - 1,
visible: is3phase,
dataLabels: {
enabled: true,
x: 38 + config.gaugesValueDistanceAdjustment,
format:
'<div style="text-align:center">' +
'<span style="font-size:' +
labelFontSize +
'px">{y}</span><br/>' +
"</div>"
}
}
]
})
);
return voltageGauge;
}