Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
<!DOCTYPE html>
<html>
<head>
<title>Capable Robot SenseTemp</title>
<script src="/chart.min.js"></script>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-title" content="SenseTemp">
</head>
<body>
<div style="width:100%">
<div>
<canvas id="canvas" height="440" width="800"></canvas>
</div>
</div>
<script>
function read_json_callback(url, callback) {
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
callback(JSON.parse(request.responseText));
}
};
request.open("GET", url, true);
request.send();
}
var ctx = document.getElementById("canvas").getContext("2d");
var chart_data = {
labels: [], // x-axis label
datasets: [
{
label: "",
borderColor: '#ff6384',
backgroundColor: '#ff6384',
data: []
}, {
label: "",
borderColor: '#36a2eb',
backgroundColor: '#36a2eb',
data: []
}, {
label: "",
borderColor: '#cc65fe',
backgroundColor: '#cc65fe',
data: []
}, {
label: "",
borderColor: '#ffce56',
backgroundColor: '#ffce56',
data: []
}
]
};
var options = {
responsive: true,
scaleShowGridLines: true,
scales: {
xAxes: [{type: 'time', unit: 'second', time: {displayFormats: {second: 'mm:ss'}}}],
},
elements: {
point: { radius: 0 },
line: { fill: false },
}
};
// scaleLineColor: "rgba(0,0,0,.1)",
var line_chart = new Chart(ctx, {
type: 'line',
data: chart_data,
options: options
});
function update_func() {
read_json_callback("/data.json", function(data) {
for (let entry of data) {
if (entry['id'] != 'agg') {
console.log(entry);
var dataset = chart_data.datasets[entry['id']-1];
if (dataset.label == "") {
dataset.label = entry['name'];
}
// TODO : retrieve scale from JSON structure
dataset.data.push(entry['value'] / 100.0);
if (dataset.data.length > 60) {
dataset.data.shift();
}
if (entry['id'] == 1) {
chart_data.labels.push(new Date());
if (chart_data.labels.length > 60) {
chart_data.labels.shift();
}
}
}
}
line_chart.update();
});
}
// TODO : pull interval from JSON file
var timer = setInterval(update_func, 500);
</script>
</body>
</html>ccd81f98fThis file is pinned to the selected release. Download the original to open it in your design tool.