feat(dm): more stats
This commit is contained in:
parent
143219ef56
commit
38091f2c1a
19 changed files with 798 additions and 1106 deletions
51
src/pages/dm/dm-messages-per-weekday.tsx
Normal file
51
src/pages/dm/dm-messages-per-weekday.tsx
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { Show, type Accessor, type Component } from "solid-js";
|
||||
import type { ChartData } from "chart.js";
|
||||
import { RadarChart } from "~/components/ui/charts";
|
||||
import { weekdayNames } from "~/lib/messages";
|
||||
import type { MessageStats, Recipients } from "~/types";
|
||||
|
||||
export const DmMessagesPerWeekday: Component<{
|
||||
weekdayStats: MessageStats["weekday"];
|
||||
recipients: Recipients;
|
||||
}> = (props) => {
|
||||
const weekdayChartData: Accessor<ChartData<"radar"> | undefined> = () => {
|
||||
const currentMessagesPerWeekday = props.weekdayStats;
|
||||
const currentRecipients = props.recipients;
|
||||
|
||||
if (currentMessagesPerWeekday && currentRecipients) {
|
||||
return {
|
||||
labels: Object.values(weekdayNames),
|
||||
datasets: [
|
||||
...currentRecipients.map((recipient) => {
|
||||
return {
|
||||
id: recipient.recipientId,
|
||||
label: `Number of messages from ${recipient.name.toString()}`,
|
||||
data: currentMessagesPerWeekday.map((weekday) => weekday[recipient.recipientId]),
|
||||
};
|
||||
}),
|
||||
],
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Show when={weekdayChartData()}>
|
||||
{(currentWeekdayChartData) => (
|
||||
<RadarChart
|
||||
options={{
|
||||
normalized: true,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
deferred: {
|
||||
yOffset: "50%",
|
||||
},
|
||||
},
|
||||
}}
|
||||
data={currentWeekdayChartData()}
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue