peltier_jacket/main.js

34 lines
937 B
JavaScript
Raw Normal View History

2016-10-14 01:58:31 +03:00
console.log("bla")
var gauge = document.getElementById('temp-gauge');
// Randomly add a data point every 500ms
var random = new TimeSeries();
setInterval(function() {
2016-10-14 02:34:01 +03:00
fetch("/temps.json").then(function (resp) {
return resp.json();
}).then(function (resp) {
console.log(resp)
var nr = Math.random() * 100;
nr = resp.pop()
random.append(new Date().getTime(), nr);
gauge.dataset.value = nr;
});
2016-10-14 01:58:31 +03:00
}, 500);
function createTimeline() {
2016-10-14 02:52:46 +03:00
var chart = new SmoothieChart({grid:{fillStyle:'transparent'}, labels:{fillStyle:'#000000'}});
2016-10-14 02:34:01 +03:00
chart.addTimeSeries(random, { strokeStyle: 'rgba(0, 0, 0, 1)', fillStyle: 'rgba(0, 0, 0, 0.1)', lineWidth: 4 });
2016-10-14 01:58:31 +03:00
chart.streamTo(document.getElementById("chart"), 500);
}
2016-10-14 02:34:01 +03:00
fetch("/temps.json").then(function (resp) {
return resp.json();
}).then(function (resp) {
console.log(resp)
for (val of resp) {
random.append(new Date().getTime(), val)
}
});
2016-10-14 01:58:31 +03:00
createTimeline();