commit 44de0c73095807dba4c68ff7a6b61d5f143dd225
parent dea4bd6e2cb1f3b32bb6b65cc2c87e920e57078d
Author: Brian Graham <brian@buildingbetterteams.de>
Date: Mon, 6 Apr 2026 06:31:44 +0200
Fix empty scatter plots: add hidden Scatter to seed axis scales
Recharts v3 only initializes axis scales when a data component exists.
The HullLayer used useXAxisScale/useYAxisScale which returned undefined
without data. Added a transparent zero-size Scatter with hull points
to seed the scales. Verified with Playwright: 6 polygons + 3 centroids
render correctly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/dashboard/src/components/ScatterPlot.tsx b/dashboard/src/components/ScatterPlot.tsx
@@ -1,8 +1,10 @@
import React from "react";
import {
ScatterChart,
+ Scatter,
XAxis,
YAxis,
+ ZAxis,
CartesianGrid,
ResponsiveContainer,
} from "recharts";
@@ -406,6 +408,13 @@ export default function ScatterPlot({
fontSize={11}
tickFormatter={(v) => yConf.format(v)}
/>
+ {/* Hidden scatter to seed axis scales with data */}
+ <ZAxis range={[0, 0]} />
+ <Scatter
+ data={regions.flatMap((r) => r.points.map((p) => ({ x: p[0], y: p[1] })))}
+ fill="transparent"
+ isAnimationActive={false}
+ />
<HullLayer
regions={regions}
centroids={centroids}