-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart.html
85 lines (79 loc) · 2.4 KB
/
chart.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
<!DOCTYPE html>
<html lang="en">
<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>Implementando o ChartJs</title>
</head>
<body>
<div style="width: 400px; display: flex; gap: 20px;">
<canvas id="first_chart"></canvas>
<canvas id="second_chart"></canvas>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const second_ctx = document.getElementById('second_chart');
const first_ctx = document.getElementById('first_chart');
new Chart(second_ctx, {
type: 'bar',
data: {
labels: ['Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho'],
datasets: [
{
label: 'Temperatura média',
data: [22, 24, 27, 23, 20, 18],
borderWidth: 1,
backgroundColor: '#836FFF'
},
{
label: 'Umidade média',
data: [90, 89, 93, 87, 88, 82],
borderWidth: 1,
backgroundColor: '#191970',
}
]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
const labels = ['12:00', '13:00', '14:00', '15:00', '16:00', '17:00'];
const data = {
labels: labels,
datasets: [{
label: 'Temperatura',
data: [30, 29, 28, 25, 22, 23],
fill: false,
borderColor: '#7FFF00',
backgroundColor: '#7FFF00',
tension: 0.1
},
{
label: 'Umidade',
data: [80, 82, 80, 85, 80, 83],
fill: false,
borderColor: '#228B22',
backgroundColor: '#228B22',
tension: 0.1
}]
};
const config = {
type: 'line',
data: data,
};
new Chart(first_ctx, config);
</script>
</body>
</html>
</body>
</html>