Skip to content

Commit 0b1ffc3

Browse files
committed
Replace NaN with 0 in choropleth visualization data
- When metric values are NaN (undefined, null, or non-numeric), treat as 0 - Prevents missing data from breaking the visualization - Shows zero values on map for regions with no data instead of being blank
1 parent 08c43a3 commit 0b1ffc3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • exec/java-exec/src/main/resources/webapp/src/components/visualization

exec/java-exec/src/main/resources/webapp/src/components/visualization/ChartPreview.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,10 +1801,14 @@ export default function ChartPreview({
18011801
const resolverFn = mapDef.resolve;
18021802

18031803
// Build choropleth data: array of { name: resolvedName, value: numericValue }
1804-
const choroData = data.rows.map((row) => ({
1805-
name: resolverFn(String(row[dimCol] ?? '')),
1806-
value: Number(row[valueCol]) || 0,
1807-
}));
1804+
// Replace NaN with 0
1805+
const choroData = data.rows.map((row) => {
1806+
const value = Number(row[valueCol]);
1807+
return {
1808+
name: resolverFn(String(row[dimCol] ?? '')),
1809+
value: isNaN(value) ? 0 : value,
1810+
};
1811+
});
18081812

18091813
// Debug logging for choropleth rendering
18101814
if (choroData.length > 0) {

0 commit comments

Comments
 (0)