Seperate webpage for the diagram
This commit is contained in:
37
data/chart.htm
Normal file
37
data/chart.htm
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>IKEA Home Sensor Diagram</title>
|
||||
<script src="/chart.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function onBodyLoad(){
|
||||
|
||||
const xhttp = new XMLHttpRequest();
|
||||
xhttp.responseType = 'json';
|
||||
xhttp.onload = function() {
|
||||
var jsonResponse = this.response;
|
||||
console.log("JSON received");
|
||||
const ctx = document.getElementById('myChart');
|
||||
const myChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: jsonResponse,
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log("Diagram generated");
|
||||
}
|
||||
xhttp.open("GET", "/diagram", true);
|
||||
xhttp.send();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body id="body" onload="onBodyLoad()">
|
||||
<canvas id="myChart" width="100%" height="100"></canvas>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user