diff --git a/package.json b/package.json index 6953e55..068e34c 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "@types/chart.js": "^2.9.41", "astro": "^4.2.4", "chart.js": "^4.4.1", + "chartjs-adapter-date-fns": "^3.0.0", + "date-fns": "^3.3.1", "lodash": "^4.17.21", "lucide-solid": "^0.319.0", "lucide-static": "^0.319.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 227118e..32b183a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,12 +1,16 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: '@astrojs/node': specifier: ^7.0.4 version: 7.0.4(astro@4.2.4) '@astrojs/solid-js': specifier: ^4.0.1 - version: 4.0.1(solid-js@1.8.12)(vite@5.1.1) + version: 4.0.1(solid-js@1.8.12)(vite@5.0.12) '@astrojs/tailwind': specifier: ^5.1.0 version: 5.1.0(astro@4.2.4)(tailwindcss@3.4.1) @@ -31,6 +35,12 @@ dependencies: chart.js: specifier: ^4.4.1 version: 4.4.1 + chartjs-adapter-date-fns: + specifier: ^3.0.0 + version: 3.0.0(chart.js@4.4.1)(date-fns@3.3.1) + date-fns: + specifier: ^3.3.1 + version: 3.3.1 lodash: specifier: ^4.17.21 version: 4.17.21 @@ -160,14 +170,14 @@ packages: dependencies: prismjs: 1.29.0 - /@astrojs/solid-js@4.0.1(solid-js@1.8.12)(vite@5.1.1): + /@astrojs/solid-js@4.0.1(solid-js@1.8.12)(vite@5.0.12): resolution: {integrity: sha512-XjViecwQDEO/e3OWCCORPYtYLS7MUNWvAWGVvNkzhAyVYZbM2fzckp94WkhX/qPu1rPUyNxSMXnN6IXkiVRTwA==} engines: {node: '>=18.14.1'} peerDependencies: solid-js: ^1.8.5 dependencies: solid-js: 1.8.12 - vite-plugin-solid: 2.9.1(solid-js@1.8.12)(vite@5.1.1) + vite-plugin-solid: 2.9.1(solid-js@1.8.12)(vite@5.0.12) transitivePeerDependencies: - '@testing-library/jest-dom' - supports-color @@ -737,14 +747,6 @@ packages: engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} dev: true - /@rollup/rollup-android-arm-eabi@4.10.0: - resolution: {integrity: sha512-/MeDQmcD96nVoRumKUljsYOLqfv1YFJps+0pTrb2Z9Nl/w5qNUysMaWQsrd1mvAlNT4yza1iVyIu4Q4AgF6V3A==} - cpu: [arm] - os: [android] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-android-arm-eabi@4.9.6: resolution: {integrity: sha512-MVNXSSYN6QXOulbHpLMKYi60ppyO13W9my1qogeiAqtjb2yR4LSmfU2+POvDkLzhjYLXz9Rf9+9a3zFHW1Lecg==} cpu: [arm] @@ -752,14 +754,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-android-arm64@4.10.0: - resolution: {integrity: sha512-lvu0jK97mZDJdpZKDnZI93I0Om8lSDaiPx3OiCk0RXn3E8CMPJNS/wxjAvSJJzhhZpfjXsjLWL8LnS6qET4VNQ==} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-android-arm64@4.9.6: resolution: {integrity: sha512-T14aNLpqJ5wzKNf5jEDpv5zgyIqcpn1MlwCrUXLrwoADr2RkWA0vOWP4XxbO9aiO3dvMCQICZdKeDrFl7UMClw==} cpu: [arm64] @@ -767,14 +761,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-darwin-arm64@4.10.0: - resolution: {integrity: sha512-uFpayx8I8tyOvDkD7X6n0PriDRWxcqEjqgtlxnUA/G9oS93ur9aZ8c8BEpzFmsed1TH5WZNG5IONB8IiW90TQg==} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-darwin-arm64@4.9.6: resolution: {integrity: sha512-CqNNAyhRkTbo8VVZ5R85X73H3R5NX9ONnKbXuHisGWC0qRbTTxnF1U4V9NafzJbgGM0sHZpdO83pLPzq8uOZFw==} cpu: [arm64] @@ -782,14 +768,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-darwin-x64@4.10.0: - resolution: {integrity: sha512-nIdCX03qFKoR/MwQegQBK+qZoSpO3LESurVAC6s6jazLA1Mpmgzo3Nj3H1vydXp/JM29bkCiuF7tDuToj4+U9Q==} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-darwin-x64@4.9.6: resolution: {integrity: sha512-zRDtdJuRvA1dc9Mp6BWYqAsU5oeLixdfUvkTHuiYOHwqYuQ4YgSmi6+/lPvSsqc/I0Omw3DdICx4Tfacdzmhog==} cpu: [x64] @@ -797,14 +775,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.10.0: - resolution: {integrity: sha512-Fz7a+y5sYhYZMQFRkOyCs4PLhICAnxRX/GnWYReaAoruUzuRtcf+Qnw+T0CoAWbHCuz2gBUwmWnUgQ67fb3FYw==} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.9.6: resolution: {integrity: sha512-oNk8YXDDnNyG4qlNb6is1ojTOGL/tRhbbKeE/YuccItzerEZT68Z9gHrY3ROh7axDc974+zYAPxK5SH0j/G+QQ==} cpu: [arm] @@ -812,14 +782,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.10.0: - resolution: {integrity: sha512-yPtF9jIix88orwfTi0lJiqINnlWo6p93MtZEoaehZnmCzEmLL0eqjA3eGVeyQhMtxdV+Mlsgfwhh0+M/k1/V7Q==} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-linux-arm64-gnu@4.9.6: resolution: {integrity: sha512-Z3O60yxPtuCYobrtzjo0wlmvDdx2qZfeAWTyfOjEDqd08kthDKexLpV97KfAeUXPosENKd8uyJMRDfFMxcYkDQ==} cpu: [arm64] @@ -827,14 +789,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-arm64-musl@4.10.0: - resolution: {integrity: sha512-9GW9yA30ib+vfFiwjX+N7PnjTnCMiUffhWj4vkG4ukYv1kJ4T9gHNg8zw+ChsOccM27G9yXrEtMScf1LaCuoWQ==} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-linux-arm64-musl@4.9.6: resolution: {integrity: sha512-gpiG0qQJNdYEVad+1iAsGAbgAnZ8j07FapmnIAQgODKcOTjLEWM9sRb+MbQyVsYCnA0Im6M6QIq6ax7liws6eQ==} cpu: [arm64] @@ -842,14 +796,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-riscv64-gnu@4.10.0: - resolution: {integrity: sha512-X1ES+V4bMq2ws5fF4zHornxebNxMXye0ZZjUrzOrf7UMx1d6wMQtfcchZ8SqUnQPPHdOyOLW6fTcUiFgHFadRA==} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-linux-riscv64-gnu@4.9.6: resolution: {integrity: sha512-+uCOcvVmFUYvVDr27aiyun9WgZk0tXe7ThuzoUTAukZJOwS5MrGbmSlNOhx1j80GdpqbOty05XqSl5w4dQvcOA==} cpu: [riscv64] @@ -857,14 +803,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-x64-gnu@4.10.0: - resolution: {integrity: sha512-w/5OpT2EnI/Xvypw4FIhV34jmNqU5PZjZue2l2Y3ty1Ootm3SqhI+AmfhlUYGBTd9JnpneZCDnt3uNOiOBkMyw==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-linux-x64-gnu@4.9.6: resolution: {integrity: sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==} cpu: [x64] @@ -872,14 +810,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-x64-musl@4.10.0: - resolution: {integrity: sha512-q/meftEe3QlwQiGYxD9rWwB21DoKQ9Q8wA40of/of6yGHhZuGfZO0c3WYkN9dNlopHlNT3mf5BPsUSxoPuVQaw==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-linux-x64-musl@4.9.6: resolution: {integrity: sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==} cpu: [x64] @@ -887,14 +817,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.10.0: - resolution: {integrity: sha512-NrR6667wlUfP0BHaEIKgYM/2va+Oj+RjZSASbBMnszM9k+1AmliRjHc3lJIiOehtSSjqYiO7R6KLNrWOX+YNSQ==} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-win32-arm64-msvc@4.9.6: resolution: {integrity: sha512-VD6qnR99dhmTQ1mJhIzXsRcTBvTjbfbGGwKAHcu+52cVl15AC/kplkhxzW/uT0Xl62Y/meBKDZvoJSJN+vTeGA==} cpu: [arm64] @@ -902,14 +824,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.10.0: - resolution: {integrity: sha512-FV0Tpt84LPYDduIDcXvEC7HKtyXxdvhdAOvOeWMWbQNulxViH2O07QXkT/FffX4FqEI02jEbCJbr+YcuKdyyMg==} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-win32-ia32-msvc@4.9.6: resolution: {integrity: sha512-J9AFDq/xiRI58eR2NIDfyVmTYGyIZmRcvcAoJ48oDld/NTR8wyiPUu2X/v1navJ+N/FGg68LEbX3Ejd6l8B7MQ==} cpu: [ia32] @@ -917,14 +831,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-win32-x64-msvc@4.10.0: - resolution: {integrity: sha512-OZoJd+o5TaTSQeFFQ6WjFCiltiYVjIdsXxwu/XZ8qRpsvMQr4UsVrE5UyT9RIvsnuF47DqkJKhhVZ2Q9YW9IpQ==} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-win32-x64-msvc@4.9.6: resolution: {integrity: sha512-jqzNLhNDvIZOrt69Ce4UjGRpXJBzhUBzawMwnaDAwyHriki3XollsewxWzOzz+4yOFDkuJHtTsZFwMxhYJWmLQ==} cpu: [x64] @@ -1457,6 +1363,16 @@ packages: '@kurkle/color': 0.3.2 dev: false + /chartjs-adapter-date-fns@3.0.0(chart.js@4.4.1)(date-fns@3.3.1): + resolution: {integrity: sha512-Rs3iEB3Q5pJ973J93OBTpnP7qoGwvq3nUnoMdtxO+9aoJof7UFcRbWcIDteXuYd1fgAvct/32T9qaLyLuZVwCg==} + peerDependencies: + chart.js: '>=2.8.0' + date-fns: '>=2.0.0' + dependencies: + chart.js: 4.4.1 + date-fns: 3.3.1 + dev: false + /chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} @@ -1590,6 +1506,10 @@ packages: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} dev: false + /date-fns@3.3.1: + resolution: {integrity: sha512-y8e109LYGgoQDveiEBD3DYXKba1jWf5BA8YU1FL5Tvm0BTdEfy54WLCwnuYWZNnzzvALy/QQ4Hov+Q9RVRv+Zw==} + dev: false + /debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: @@ -3096,15 +3016,6 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.2 - /postcss@8.4.35: - resolution: {integrity: sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==} - engines: {node: ^10 || ^12 || >=14} - dependencies: - nanoid: 3.3.7 - picocolors: 1.0.0 - source-map-js: 1.0.2 - dev: false - /prebuild-install@7.1.1: resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==} engines: {node: '>=10'} @@ -3397,29 +3308,6 @@ packages: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - /rollup@4.10.0: - resolution: {integrity: sha512-t2v9G2AKxcQ8yrG+WGxctBes1AomT0M4ND7jTFBCVPXQ/WFTvNSefIrNSmLKhIKBrvN8SG+CZslimJcT3W2u2g==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - dependencies: - '@types/estree': 1.0.5 - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.10.0 - '@rollup/rollup-android-arm64': 4.10.0 - '@rollup/rollup-darwin-arm64': 4.10.0 - '@rollup/rollup-darwin-x64': 4.10.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.10.0 - '@rollup/rollup-linux-arm64-gnu': 4.10.0 - '@rollup/rollup-linux-arm64-musl': 4.10.0 - '@rollup/rollup-linux-riscv64-gnu': 4.10.0 - '@rollup/rollup-linux-x64-gnu': 4.10.0 - '@rollup/rollup-linux-x64-musl': 4.10.0 - '@rollup/rollup-win32-arm64-msvc': 4.10.0 - '@rollup/rollup-win32-ia32-msvc': 4.10.0 - '@rollup/rollup-win32-x64-msvc': 4.10.0 - fsevents: 2.3.3 - dev: false - /rollup@4.9.6: resolution: {integrity: sha512-05lzkCS2uASX0CiLFybYfVkwNbKZG5NFQ6Go0VWyogFTXXbR039UVsegViTntkk4OglHBdF54ccApXRRuXRbsg==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -4081,7 +3969,7 @@ packages: unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 - /vite-plugin-solid@2.9.1(solid-js@1.8.12)(vite@5.1.1): + /vite-plugin-solid@2.9.1(solid-js@1.8.12)(vite@5.0.12): resolution: {integrity: sha512-RC4hj+lbvljw57BbMGDApvEOPEh14lwrr/GeXRLNQLcR1qnOdzOwwTSFy13Gj/6FNIZpBEl0bWPU+VYFawrqUw==} peerDependencies: '@testing-library/jest-dom': ^5.16.6 || ^5.17.0 || ^6.* @@ -4097,8 +3985,8 @@ packages: merge-anything: 5.1.7 solid-js: 1.8.12 solid-refresh: 0.6.3(solid-js@1.8.12) - vite: 5.1.1(@types/node@20.11.17) - vitefu: 0.2.5(vite@5.1.1) + vite: 5.0.12(@types/node@20.11.17) + vitefu: 0.2.5(vite@5.0.12) transitivePeerDependencies: - supports-color dev: false @@ -4138,42 +4026,6 @@ packages: optionalDependencies: fsevents: 2.3.3 - /vite@5.1.1(@types/node@20.11.17): - resolution: {integrity: sha512-wclpAgY3F1tR7t9LL5CcHC41YPkQIpKUGeIuT8MdNwNZr6OqOTLs7JX5vIHAtzqLWXts0T+GDrh9pN2arneKqg==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@types/node': ^18.0.0 || >=20.0.0 - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - dependencies: - '@types/node': 20.11.17 - esbuild: 0.19.12 - postcss: 8.4.35 - rollup: 4.10.0 - optionalDependencies: - fsevents: 2.3.3 - dev: false - /vitefu@0.2.5(vite@5.0.12): resolution: {integrity: sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==} peerDependencies: @@ -4184,17 +4036,6 @@ packages: dependencies: vite: 5.0.12(@types/node@20.11.17) - /vitefu@0.2.5(vite@5.1.1): - resolution: {integrity: sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==} - peerDependencies: - vite: ^3.0.0 || ^4.0.0 || ^5.0.0 - peerDependenciesMeta: - vite: - optional: true - dependencies: - vite: 5.1.1(@types/node@20.11.17) - dev: false - /web-namespaces@2.0.1: resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==} @@ -4297,7 +4138,3 @@ packages: astro: 4.2.4(@types/node@20.11.17) ultrahtml: 1.5.2 dev: true - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false diff --git a/src/components/widgets/BarChart.tsx b/src/components/widgets/BarChart.tsx new file mode 100644 index 0000000..49286d1 --- /dev/null +++ b/src/components/widgets/BarChart.tsx @@ -0,0 +1,64 @@ +// @ts-nocheck + +import { onMount } from "solid-js" +import { Chart, Title, Tooltip, Colors, TimeScale, type ChartOptions, type ChartData } from "chart.js" +import { Bar } from "solid-chartjs" +import "chartjs-adapter-date-fns" + +type BarChartProps = { + labels: string[] + data: number[] + labelObjectName: string + useTimeScale?: boolean +} + +const longNumberFormatter = new Intl.NumberFormat("en-us") + +export function BarChart(props: BarChartProps) { + let canvas: HTMLCanvasElement + onMount(() => { + Chart.register(Title, Tooltip, Colors, TimeScale) + }) + + const chartData: ChartData = { + labels: props.labels, + datasets: [ + { + data: props.data, + backgroundColor: "#5EC269", + }, + ], + } + + const chartOptions: ChartOptions = { + responsive: true, + maintainAspectRatio: true, + animation: false, + interaction: { + intersect: false, + mode: "index", + }, + scales: { + x: props.useTimeScale + ? { + type: "time", + time: { unit: "day", tooltipFormat: "d MMM, y" }, + } + : {}, + }, + plugins: { + tooltip: { + displayColors: false, + callbacks: { + label: (c) => `${longNumberFormatter.format(c.parsed.y)} ${props.labelObjectName}`, + }, + }, + }, + } + + return ( +
+ In total, {longNumberFormatter.format(activity.aggregated.matches)} ranked games were played since { + earliestDate.toLocaleDateString("en", { dateStyle: "long" }) + }. +
++ In total, {longNumberFormatter.format(activity.aggregated.players)} persons played on the ladder since { + earliestDate.toLocaleDateString("en", { dateStyle: "long" }) + }. +
+