Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor chart components to improve data boundary handling

Bill Yangdbd1c0842c7c
diff --git a/client/src/app/[site]/bots/components/BotChart.tsx b/client/src/app/[site]/bots/components/BotChart.tsx
index 57382f85d..43e3fb0a3 100644
--- a/client/src/app/[site]/bots/components/BotChart.tsx
+++ b/client/src/app/[site]/bots/components/BotChart.tsx
@@ -56,8 +56,8 @@ export function BotChart() {
return {
current: points,
- chartMin: boundsMin ?? dataMin,
- chartMax: boundsMax ?? dataMax ?? now.toJSDate(),
+ chartMin: dataMin ?? boundsMin,
+ chartMax: dataMax ?? boundsMax ?? now.toJSDate(),
max: points.reduce((largest, point) => Math.max(largest, point.y), 0),
};
}, [bucket, time, timeSeriesData, timezone]);
diff --git a/client/src/app/[site]/performance/components/PerformanceChart.tsx b/client/src/app/[site]/performance/components/PerformanceChart.tsx
index 7684dc255..b2b0d93c2 100644
--- a/client/src/app/[site]/performance/components/PerformanceChart.tsx
+++ b/client/src/app/[site]/performance/components/PerformanceChart.tsx
@@ -145,8 +145,8 @@ export function PerformanceChart() {
return {
current: chartSeries[0]?.data ?? [],
chartSeries,
- chartMin: boundsMin ?? dataMin,
- chartMax: boundsMax ?? dataMax ?? now.toJSDate(),
+ chartMin: dataMin ?? boundsMin,
+ chartMax: dataMax ?? boundsMax ?? now.toJSDate(),
max,
};
}, [bucket, selectedPerformanceMetric, time, timeSeriesData, timezone, visiblePercentiles]);