From 0e481c73c2966c072a9a814a45cf138145e9028d Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 17 Dec 2023 02:32:24 -0800 Subject: feat(activities): cool chart --- src/lib/Tools/ActivityHistory.svelte | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/lib/Tools/ActivityHistory.svelte') diff --git a/src/lib/Tools/ActivityHistory.svelte b/src/lib/Tools/ActivityHistory.svelte index 122a7513..57037f15 100644 --- a/src/lib/Tools/ActivityHistory.svelte +++ b/src/lib/Tools/ActivityHistory.svelte @@ -16,6 +16,7 @@ let activityHistoryData: Promise; let currentUserIdentity = { name: '', id: -1 }; + let baseHue = Math.floor(Math.random() * 360); onMount(async () => { clearAllParameters(); @@ -34,6 +35,12 @@ // return date; // }; + + const gradientColour = (amount: number, maxAmount: number, baseHue: number) => { + const lightness = 100 - Math.round((amount / maxAmount) * 50); + + return `hsl(${baseHue}, 100%, ${lightness}%)`; + };
@@ -49,6 +56,26 @@ {#if activities === undefined} Loading ... {:else} + {@const highestActivity = Math.max(...activities.map((activity) => activity.amount))} + +
+ {#each activities as activity} +
(baseHue = Math.floor(Math.random() * 360))} + on:keydown={() => {}} + role="button" + tabindex="0" + title={`Date: ${new Date(activity.date * 1000).toLocaleDateString()}\nAmount: ${ + activity.amount + }`} + /> + {/each} +
+ +

+

    {#each fillMissingDays(activities) as activity} {#if activity.amount === 0} @@ -63,3 +90,21 @@ {/if} {/await} {/if} + + -- cgit v1.2.3