-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchart.mjs
More file actions
74 lines (68 loc) · 1.51 KB
/
Copy pathchart.mjs
File metadata and controls
74 lines (68 loc) · 1.51 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
let indexI = [0, 24, 48, 72, 96, 120, 144];
let indexF = [24, 48, 72, 96, 120, 144, 168];
export function loadChart(hourly, dia) {
myChart.data.labels = [];
myChart.data.datasets[0].data = [];
hourly.slice(indexI[dia], indexF[dia]).forEach((hour) => {
let date = new Date(hour.timeStamp);
let fDate = date.toLocaleTimeString().slice(0, 2);
let temp = hour.temp;
myChart.data.labels.push(fDate.toString() + "h");
myChart.data.datasets[0].data.push(temp);
});
myChart.update();
}
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: "line",
data: {
labels: [],
datasets: [
{
label: "Temperatura",
data: [],
backgroundColor: ["rgba(255, 255, 255, 1)"],
borderColor: ["rgba(255,255,255,1)"],
borderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: '#2d9ee0',
},
],
},
options: {
plugins: {
tooltip: {
displayColors: false,
},
legend: {
display: false,
},
},
scales: {
x: {
border: {
color: "white",
},
ticks: {
color: "white",
},
grid: {
color: "white",
borderColor: "white",
display: false,
},
},
y: {
suggestedMin: 0,
suggestedMax: 25,
border: {
color: "white",
},
ticks: { color: "white" },
grid: {
display: false,
},
},
},
},
});