From a954e89b47bf55233f0ebfa248b6a970dd30c410 Mon Sep 17 00:00:00 2001 From: Joey Eamigh <55670930+JoeyEamigh@users.noreply.github.com> Date: Wed, 11 Feb 2026 05:50:09 -0500 Subject: [PATCH] fix: map EIA fuel type codes to display names in generation chart EIA stores fuel types as codes (NG, NUC, WND, SUN, COL, WAT) but the chart expected display names (gas, nuclear, wind, solar, coal, hydro). All data was falling through to "other". Added EIA_FUEL_MAP lookup in pivotGenerationData to resolve codes before categorizing. --- src/components/charts/generation-chart.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/charts/generation-chart.tsx b/src/components/charts/generation-chart.tsx index 238a299..04ff06a 100644 --- a/src/components/charts/generation-chart.tsx +++ b/src/components/charts/generation-chart.tsx @@ -66,10 +66,24 @@ const FOSSIL_FUELS = new Set(['gas', 'coal']); const FUEL_TYPE_SET: Set = new Set(FUEL_TYPES); +/** Map EIA fuel type codes to display names */ +const EIA_FUEL_MAP: Record = { + NG: 'gas', + NUC: 'nuclear', + WND: 'wind', + SUN: 'solar', + COL: 'coal', + WAT: 'hydro', +}; + function isFuelType(value: string): value is FuelType { return FUEL_TYPE_SET.has(value); } +function resolveFuelType(raw: string): FuelType { + return EIA_FUEL_MAP[raw] ?? (isFuelType(raw) ? raw : 'other'); +} + const TIME_RANGE_SET: Set = new Set(['24h', '7d', '30d', '90d', '1y']); function isTimeRange(value: string): value is TimeRange { @@ -113,7 +127,7 @@ function pivotGenerationData(rows: getGenerationMix.Result[], regionCode: string byTimestamp.set(ts, pivot); } - const fuelKey = isFuelType(row.fuel_type) ? row.fuel_type : 'other'; + const fuelKey = resolveFuelType(row.fuel_type); pivot[fuelKey] += row.generation_mw; }