Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Update chart-component CustomizedDot function to not throw NaN error

ZachTRice9b40aea0aad7
diff --git a/web/js/components/charting/chart-component.js b/web/js/components/charting/chart-component.js
index e2d40c871..40042e025 100644
--- a/web/js/components/charting/chart-component.js
+++ b/web/js/components/charting/chart-component.js
@@ -225,9 +225,15 @@ function ChartComponent (props) {
payload,
} = props;
- if (!payload.mean) return;
-
- const radius = pointSizes[Math.max(Math.floor(chartData.length / 26), 1) - 1];
+ // Guard: skip if coordinates or value are not finite numbers
+ if (!Number.isFinite(cx) || !Number.isFinite(cy)) return null;
+ if (!Number.isFinite(payload?.mean)) return null;
+
+ // Determine a safe radius based on dataset length with clamping + fallback
+ const len = Number.isFinite(chartData?.length) && chartData.length > 0 ? chartData.length : 1;
+ const idxBase = Math.max(Math.floor(len / 26), 1) - 1; // 0 for <26, 1 for 26–51, etc.
+ const idx = Math.min(pointSizes.length - 1, Math.max(0, idxBase));
+ const radius = pointSizes[idx] ?? 2; // fallback radius
const transformFunc = `translate(${radius + 1} ${radius + 1})`;