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.
This commit is contained in:
parent
f053a3a53b
commit
a954e89b47
@ -66,10 +66,24 @@ const FOSSIL_FUELS = new Set<FuelType>(['gas', 'coal']);
|
||||
|
||||
const FUEL_TYPE_SET: Set<string> = new Set(FUEL_TYPES);
|
||||
|
||||
/** Map EIA fuel type codes to display names */
|
||||
const EIA_FUEL_MAP: Record<string, FuelType> = {
|
||||
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<string> = 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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user