-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart.js
58 lines (57 loc) · 1.4 KB
/
chart.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
46
47
48
49
50
51
52
53
54
55
56
57
58
function range(num, start) {
let set = [];
for(let i = 0; i < num; i++) {
set.push(i + start);
}
return set;
}
var ctx = document.getElementById("chart").getContext('2d');
//var labels = range(skdata.length, 1);
var mychart = new Chart(ctx, {
type: 'line',
data: {
labels: [],
datasets: [{
label: "Sick people",
data: [],
fill: false,
borderColor: 'rgb(192, 75, 75)',
tension: 0.1
},
{
label: "Immune people",
data: [],
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
},
{
label: "Uninfected people",
data: [],
fill: false,
borderColor: 'rgb(75, 75, 192)',
tension: 0.1
},
{
label: "Dead people",
data: [],
fill: false,
borderColor: 'rgb(75, 75, 75)',
tension: 0.1
}]
}
});
function addData(chart, didx, data) {
chart.data.datasets[didx].data.push(data);
chart.update();
}
function addLabel(chart, label) {
chart.data.labels.push(label);
}
function removeData(chart) {
chart.data.labels.pop();
chart.data.datasets.forEach((dataset) => {
dataset.data.pop();
});
chart.update();
}