-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
125 lines (119 loc) · 2.97 KB
/
index.html
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
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE HTML>
<html>
<head>
<title>UPS Statistics</title>
<script type="text/javascript" src="libs/jquery-3.6.0.min.js"></script>
<meta charset="UTF-8">
<script>
window.onload = function () {
var dataPointsLoad = [];
var dataPointsTime = [];
var dataPointsVolt = [];
//Replace text file's path according to your requirement.
jQuery.get("data.txt", function(data) {
var allLines = data.split('\n');
if (allLines.length > 0) {
for (var i = 0; i < allLines.length; i++) {
allLines[i] = allLines[i].replace(/(\r\n|\n|\r)/gm, "");
dataPointsLoad.push({
x: parseInt(allLines[i].split(" ")[0]), // timestamp
y: parseInt(allLines[i].split(" ")[1]) // load
});
dataPointsTime.push({
x: parseInt(allLines[i].split(" ")[0]), // timestamp
y: parseInt(allLines[i].split(" ")[2]) // battery time
})
dataPointsVolt.push({
x: parseInt(allLines[i].split(" ")[0]), // timestamp
y: parseFloat(allLines[i].split(" ")[3]) // voltage
})
}
}
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title:{
text: "UPS load and battery life in time"
},
toolTip: {
shared: true
},
axisX: {
title: "Time (last 24h)",
valueFormatString: "HH:mm",
suffix : ""
},
axisY: {
title: "UPS load (%)",
titleFontColor: "#4F81BC",
suffix : " %",
lineColor: "#4F81BC",
tickColor: "#4F81BC"
},
axisY2: {
title: "UPS battery life (min)",
titleFontColor: "#C0504E",
suffix : " min",
lineColor: "#C0504E",
tickColor: "#C0504E"
},
data: [{
type: "spline",
name: "Load (%)",
xValueType: "dateTime",
xValueFormatString: "D MMM Y HH:mm",
yValueFormatString: "# '%'",
dataPoints: []
},
{
type: "spline",
axisYType: "secondary",
name: "Battery time (min)",
yValueFormatString: "#,##0.# min",
dataPoints: []
}]
});
chart.options.data[0].dataPoints = dataPointsLoad;
chart.options.data[1].dataPoints = dataPointsTime;
chart.render();
var chart2 = new CanvasJS.Chart("chartContainer2", {
animationEnabled: true,
title:{
text: "UPS input voltage in time"
},
toolTip: {
shared: true
},
axisX: {
title: "Time (last 24h)",
valueFormatString: "HH:mm",
suffix : ""
},
axisY: {
title: "UPS input voltage (V)",
titleFontColor: "#4F81BC",
suffix : " V",
lineColor: "#4F81BC",
tickColor: "#4F81BC"
},
data: [{
type: "spline",
name: "Input voltage (V)",
xValueType: "dateTime",
xValueFormatString: "D MMM Y HH:mm",
yValueFormatString: "#.0 'V'",
dataPoints: []
}]
});
chart2.options.data[0].dataPoints = dataPointsVolt;
chart2.render();
});
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
<br><br><br>
<div id="chartContainer2" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
<script src="libs/canvasjs.min.js"></script>
</body>
</html>