Skip to content

Commit

Permalink
incomplete stats menu
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Mar 4, 2024
1 parent 29095bb commit 800a660
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@astrojs/tailwind": "^5.1.0",
"astro": "^4.4.9",
"astro-feather": "^1.0.0",
"chart.js": "^4.4.2",
"tailwindcss": "^3.4.1"
}
}
23 changes: 23 additions & 0 deletions src/components/PlayerStats.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
---

<canvas class="player-stats" width="500" height="300"></canvas>

<script>
import { Chart } from 'chart.js/auto';

const data = await (await fetch(
'https://globed.dankmeme.dev/public/players?period=hour',
{
mode: 'no-cors'
}
)).json();
document.querySelectorAll('.player-stats').forEach(canvas => {
const chart = new Chart(canvas as HTMLCanvasElement, {
type: 'line',
data: data,
});
});

</script>
3 changes: 3 additions & 0 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Title from '../components/Title.astro';
import Subtitle from '../components/Subtitle.astro';
import ButtonRow from '../components/ButtonRow.astro';
import Content from '../components/Content.astro';
import PlayerStats from '../components/PlayerStats.astro';
const screenshots = (await Astro.glob('../images/screenshot-*.png')).map(file => file.default);
---
Expand Down Expand Up @@ -94,6 +95,8 @@ const screenshots = (await Astro.glob('../images/screenshot-*.png')).map(file =>
</div>
</Content>

<!-- <PlayerStats/> -->

<Donate />

</Page>

0 comments on commit 800a660

Please sign in to comment.