44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
var ctx = document.getElementById('myChart').getContext('2d');
|
|
var myChart = new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: new Array(GRAPH_RES),
|
|
datasets: [{
|
|
label: 'Ublox',
|
|
backgroundColor: 'rgba(214, 69, 65, 1)',
|
|
borderColor: 'rgba(214, 69, 65, 1)',
|
|
borderWidth: 1,
|
|
fill: false,
|
|
pointRadius: 0,
|
|
lineTension: 0.5,
|
|
data: new Array(GRAPH_RES)
|
|
}]
|
|
},
|
|
options: {
|
|
scales: {
|
|
yAxes: [{
|
|
ticks: {
|
|
// beginAtZero: true
|
|
min: -2000,
|
|
max: 2000
|
|
}
|
|
}]
|
|
},
|
|
animation: {
|
|
duration: 0
|
|
}
|
|
}
|
|
});
|
|
myChart.data.labels.fill("", 0, GRAPH_RES);
|
|
myChart.data.datasets.forEach((dataset) => dataset.data.fill(0, 0, GRAPH_RES))
|
|
function addSerialAltData(data) {
|
|
myChart.data.labels.push("");
|
|
myChart.data.datasets.forEach((dataset) => {
|
|
dataset.data.push(data);
|
|
});
|
|
while (myChart.data.labels.length >= GRAPH_RES) {
|
|
myChart.data.labels.shift();
|
|
myChart.data.datasets.forEach((dataset) => dataset.data.shift())
|
|
}
|
|
myChart.update();
|
|
}; |