console.log("bla") var gauge = document.getElementById('temp-gauge'); // Randomly add a data point every 500ms var random = new TimeSeries(); setInterval(function() { 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; }); }, 500); function createTimeline() { var chart = new SmoothieChart({grid:{fillStyle:'transparent'}, labels:{fillStyle:'#000000'}}); chart.addTimeSeries(random, { strokeStyle: 'rgba(0, 0, 0, 1)', fillStyle: 'rgba(0, 0, 0, 0.1)', lineWidth: 4 }); chart.streamTo(document.getElementById("chart"), 500); } 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) } }); function heat(h) { fetch("/heat",{ method: 'POST', body: JSON.stringify({message:h})}) } createTimeline();