-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrafico.js
45 lines (36 loc) · 931 Bytes
/
grafico.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const socket = io();
let counter = 1;
socket.on('serial:data', function(dataSerial){
console.log(dataSerial.value + 'L/min');
myChart.data.labels.push(counter);
myChart.data.datasets.forEach(dataset => {
dataset.data.push(dataSerial.value);
});
counter=counter+1;
myChart.update();
});
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['Serial'],
datasets: [{
label: 'Serial',
data: [],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(0, 0, 0, 0.5)',
],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});