🙏⛳️ Checkpoint

./public/index.js:1954897/89981
This commit is contained in:
Glitch (glitch-hello-node) committed 2021-11-14 07:24:11 +00:00
1 parent ad6446ed34
commit ab8b5e0e3b
2 files changed
+50 -21

No files matched your search

+12 -21
View File
@@ -121,7 +121,7 @@ async function displayCard(id) {
<canvas id="myChart" height="80"></canvas>
`
card.style.setProperty("--region", `'${id}'`)
updateChart()
updateChart(data)
await card.animate([
{ transform: 'translateY(0%)', opacity: "1" },
], {
@@ -132,31 +132,19 @@ async function displayCard(id) {
}
function updateChart() {
function updateChart(data) {
// { loc, time: new Date(+time), count: parseInt(count) }
const parsed = data.map(d => ({ x: d.time, y: d.count }))
const ctx = document.getElementById('myChart').getContext('2d')
new Chart(ctx, {
type: 'line',
data: {
labels: ['Now', '1h ago', '2h ago', '3h ago', '4h ago', '5h ago'].reverse(),
// labels: ['Now', '1h ago', '2h ago', '3h ago', '4h ago', '5h ago'].reverse(),
datasets: [{
label: 'Density',
data: [12, 19, 3, 5, 2, 3],
// backgroundColor: [
// 'rgba(255, 99, 132, 0.2)',
// 'rgba(54, 162, 235, 0.2)',
// 'rgba(255, 206, 86, 0.2)',
// 'rgba(75, 192, 192, 0.2)',
// 'rgba(153, 102, 255, 0.2)',
// 'rgba(255, 159, 64, 0.2)'
// ],
// borderColor: [
// 'rgba(255, 99, 132, 1)',
// 'rgba(54, 162, 235, 1)',
// 'rgba(255, 206, 86, 1)',
// 'rgba(75, 192, 192, 1)',
// 'rgba(153, 102, 255, 1)',
// 'rgba(255, 159, 64, 1)'
// ],
data: parsed,
borderColor: '#55aadd',
backgroundColor: '#55aadd',
// borderWidth: 2
@@ -164,8 +152,11 @@ function updateChart() {
},
options: {
scales: {
x: {
beginAtZero: true,
},
y: {
beginAtZero: true
beginAtZero: true,
}
}
}