-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartJs.html
103 lines (88 loc) · 2.24 KB
/
ChartJs.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Implementação do ChartJs</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body style="display: flex;">
<div>
<canvas id="myChart" style="position: relative; height:40vh; width:40vw"></canvas>
</div>
<div>
<canvas id="myChart2" style="position: relative; height:40vh; width:40vw"></canvas>
</div>
</body>
</html>
<script>
const labels = [
'12:00',
'13:00',
'14:00',
'15:00',
'16:00',
'17:00',
];
const data = {
labels: labels,
datasets: [{
label: 'Temperatura',
backgroundColor: 'rgb(255, 0, 0)',
borderColor: 'rgb(255, 0, 0)',
data: [30, 29, 28, 25, 22, 23, ],
},
{
label: 'Umidade',
backgroundColor: 'rgb(0, 0, 255)',
borderColor: 'rgb(0, 0, 255)',
data: [80, 82, 80, 85, 80, 83, ],
}
]
};
const labels2 = [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
];
const data2 = {
labels: labels2,
datasets: [{
label: 'Temperatura Média',
backgroundColor: 'rgb(255, 0, 0)',
borderColor: 'rgb(255, 0, 0)',
data: [22, 24, 27, 23, 20, 18, ],
},
{
label: 'Umidade Media',
backgroundColor: 'rgb(0, 0, 255)',
borderColor: 'rgb(0, 0, 255)',
data: [90, 89, 93, 87, 88, 82, ],
}
]
};
const config = {
type: 'line',
data: data,
options: {}
};
const config2 = {
type: 'bar',
data: data2,
options: {}
};
</script>
<script>
const myChart = new Chart(
document.getElementById('myChart'),
config
);
const myChart2 = new Chart(
document.getElementById('myChart2'),
config2
);
</script>