🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Enhance chart boundary logic and update data fetching in MainSection
Bill Yangd527c381eec6
diff --git a/client/src/app/[site]/main/components/MainSection/Chart.tsx b/client/src/app/[site]/main/components/MainSection/Chart.tsxindex a4b6e4747..14a458d0a 100644--- a/client/src/app/[site]/main/components/MainSection/Chart.tsx+++ b/client/src/app/[site]/main/components/MainSection/Chart.tsx@@ -393,8 +393,16 @@ export function Chart({const dataMax = currentPoints.length? currentPoints[currentPoints.length - 1].x: undefined;+ const chartXMaxMs = chartXMax?.getTime();+ const boundedChartXMax =+ chartXMax &&+ chartXMaxMs !== undefined &&+ (lowerBoundMs === undefined || chartXMaxMs >= lowerBoundMs) &&+ chartXMaxMs <= upperBoundMs+ ? chartXMax+ : undefined;const effChartMin = cMin ?? dataMin;- const effChartMax = chartXMax ?? boundsMax ?? dataMax ?? now.toJSDate();+ const effChartMax = boundedChartXMax ?? boundsMax ?? dataMax ?? now.toJSDate();// Previous points — time-shift onto the current period's x-axis. Each// previous timestamp is shifted by (cMin - prevMin), so prev[0] lands atdiff --git a/client/src/app/[site]/main/components/MainSection/MainSection.tsx b/client/src/app/[site]/main/components/MainSection/MainSection.tsxindex 56f1a61fe..3d80809e1 100644--- a/client/src/app/[site]/main/components/MainSection/MainSection.tsx+++ b/client/src/app/[site]/main/components/MainSection/MainSection.tsx@@ -41,7 +41,7 @@ export function MainSection() {};// Current period data- const { data, isFetching, error } = useGetOverviewBucketed({+ const { data, isFetching, isPlaceholderData, error } = useGetOverviewBucketed({site,bucket,});@@ -75,6 +75,7 @@ export function MainSection() {// overlay shows the full prior period as a backdrop.const timezone = getTimezone();const chartXMax = (() => {+ if (isPlaceholderData) return undefined;if (time.mode !== "range") return undefined;const points = data?.data;if (!points?.length) return undefined;