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; }