From 19783a9002499f07e04e31ade6eb89d8aa4e83fa Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 25 Apr 2023 18:31:04 -0700 Subject: [PATCH] mmm matrix math yummy --- packages/client/src/components/MkHeatmap.vue | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/MkHeatmap.vue b/packages/client/src/components/MkHeatmap.vue index d11287fa1c..60508095c6 100644 --- a/packages/client/src/components/MkHeatmap.vue +++ b/packages/client/src/components/MkHeatmap.vue @@ -43,6 +43,8 @@ const { handler: externalTooltipHandler } = useChartTooltip({ position: "middle", }); +const addArrays = (arr1: number[], arr2: number[], arr3: number[]) => (arr1.length === arr2.length && arr2.length === arr3.length) ? arr1.map((val, i) => val + arr2[i] + arr3[i]) : null; + async function renderChart() { if (chartInstance) { chartInstance.destroy(); @@ -115,13 +117,7 @@ async function renderChart() { span: "day", userId: $i.id, }); - values = raw.diffs.normal.map((_, i) => ({ - total: - raw.diffs.normal[i] + raw.diffs.reply[i] + raw.diffs.renote[i], - notes: raw.diffs.normal[i], - replies: raw.diffs.reply[i], - renotes: raw.diffs.renote[i], - })); + values = addArrays(raw.diffs.normal, raw.diffs.reply, raw.diffs.renote); } fetching = false;