fix(world-map): add fallback fill color when colorFn returns null (#38602)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit ba7271b4d8)
This commit is contained in:
Rafael Benitez
2026-03-13 12:02:03 -03:00
committed by Michael S. Molina
parent 4baedcc794
commit aaaead02f1
2 changed files with 63 additions and 4 deletions

View File

@@ -150,14 +150,20 @@ function WorldMap(element: HTMLElement, props: WorldMapProps): void {
fillColor: colorFn(d.name, sliceId),
}));
} else {
colorFn = getSequentialSchemeRegistry()
.get(linearColorScheme)
.createLinearScale(d3Extent(filteredData, d => d.m1));
const rawExtents = d3Extent(filteredData, d => d.m1);
const extents: [number, number] =
rawExtents[0] != null && rawExtents[1] != null
? [rawExtents[0], rawExtents[1]]
: [0, 1];
const colorSchemeObj = getSequentialSchemeRegistry().get(linearColorScheme);
colorFn = colorSchemeObj
? colorSchemeObj.createLinearScale(extents)
: () => theme.colorBorder;
processedData = filteredData.map(d => ({
...d,
radius: radiusScale(Math.sqrt(d.m2)),
fillColor: colorFn(d.m1),
fillColor: colorFn(d.m1) ?? theme.colorBorder,
}));
}