forked from STREIN-11/Intel_Unnati
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_index1.php
More file actions
60 lines (53 loc) · 1.42 KB
/
Copy pathnew_index1.php
File metadata and controls
60 lines (53 loc) · 1.42 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
<?php
$y = array(trim(file_get_contents('test.txt')));
foreach ($y as $key) {
$dataPoints = array();
array_push($dataPoints,array("label"=> "Core 1", "y"=> $key));
}
?>
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title: {
text: "Water Level Measure"
},
axisY: {
minimum: 0,
maximum: 100,
suffix: "%"
},
data: [{
type: "column",
yValueFormatString: "#,##0.00\"%\"",
indexLabel: "{y}",
dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
}]
});
function updateChart() {
var color,deltaY, yVal;
var dps = chart.options.data[0].dataPoints;
for (var i = 0; i < dps.length; i++) {
deltaY = 0;
deltaY++;
yVal = Math.min(Math.max(dps[i].y, 0), 90);
color = yVal > 75 ? "#FF2500" : yVal >= 50 ? "#FF6000" : yVal < 50 ? "#41CF35" : null;
dps[i] = {label: "Core "+(i+1) , y: yVal, color: color};
}
chart.options.data[0].dataPoints = dps;
chart.render();
};
updateChart();
setInterval(function () { updateChart() }, 1000);
}
</script>
</head>
<body>
<div align="center">
<div id="chartContainer" style="height: 370px; width: 55%;"></div></div>
<script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<button onClick="window.location.reload();">Update Data</button>
</body>
</html>