Skip to content

Commit

Permalink
add online players stats
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Mar 4, 2024
1 parent dbcaf6c commit bc80a65
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/PlayerStats.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
import Subtitle from "./Subtitle.astro";
---

<div class="bg-quardiary-darker p-8 rounded-xl max-w-paragraph">
<canvas class="player-stats"></canvas>
<div class="flex flex-col items-center gap-4">
<Subtitle>Online Players</Subtitle>
<div class="bg-wallpaper-darkest bg-opacity-50 p-8 rounded-xl max-w-paragraph">
<canvas class="player-stats"></canvas>
</div>
</div>

<script>
Expand All @@ -17,14 +22,14 @@
const chart = new Chart(canvas as HTMLCanvasElement, {
type: 'line',
data: {
labels: data.map(row => new Date(row.log_time).toDateString()),
labels: data.map(row => new Date(row.log_time * 1000).toLocaleTimeString()),
datasets: [
{
label: 'Players',
data: data.map(row => row.count),
}
]
}
},
});
});
</script>

0 comments on commit bc80a65

Please sign in to comment.