🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Update charts to support stacked view for user breakdown
Chris Rimmer3cc09fdd0a52
diff --git a/client/src/app/[site]/main/components/MainSection/Chart.tsx b/client/src/app/[site]/main/components/MainSection/Chart.tsxindex 6482c9d44..78a8d7e9c 100644--- a/client/src/app/[site]/main/components/MainSection/Chart.tsx+++ b/client/src/app/[site]/main/components/MainSection/Chart.tsx@@ -312,7 +312,7 @@ export function Chart({yScale={{type: "linear",min: 0,- stacked: false,+ stacked: showUserBreakdown,reverse: false,max: Math.max(max, 1),}}diff --git a/client/src/app/[site]/main/components/MainSection/MainSection.tsx b/client/src/app/[site]/main/components/MainSection/MainSection.tsxindex 2686cde46..6e810b682 100644--- a/client/src/app/[site]/main/components/MainSection/MainSection.tsx+++ b/client/src/app/[site]/main/components/MainSection/MainSection.tsx@@ -61,7 +61,15 @@ export function MainSection() {const activeKeys = showUserBreakdown ? (["new_users", "returning_users"] as const) : ([selectedStat] as const);const getMaxValue = (dataset?: { data?: { [key: string]: number }[] }) =>- Math.max(...(dataset?.data?.map(d => Math.max(...activeKeys.map(key => d?.[key] ?? 0))) ?? [0]));+ Math.max(+ ...(+ dataset?.data?.map(d =>+ showUserBreakdown+ ? (d?.["new_users"] ?? 0) + (d?.["returning_users"] ?? 0)+ : Math.max(...activeKeys.map(key => d?.[key] ?? 0))+ ) ?? [0]+ )+ );const maxOfDataAndPreviousData = Math.max(getMaxValue(data), getMaxValue(previousData));diff --git a/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx b/client/src/app/[site]/main/components/MainSection/PreviousChart.tsxindex 1da9dac0d..0566569aa 100644--- a/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx+++ b/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx@@ -115,7 +115,7 @@ export function PreviousChart({yScale={{type: "linear",min: 0,- stacked: false,+ stacked: showUserBreakdown,reverse: false,max: Math.max(max, 1),}}