Bug description
Data (totalExport and totalImport) is available for an electric net exchange chart with 30d+ views, but it's only presented for the 24h and 72h views.
There isn't data about totalCo2Export or totalCo2Import, so this issue is down-scoped to getting the electric net exchange chart to avoid addressing separate underlying problems. I've opened #7596 to address that.
Click to expand electric net exchange chart screenshots
| 72h view |
all view (with bug fixed) |
 |
 |
Analysis
The reason for 30d+ views not presenting the net exchange chart stems from a detail in a low-level helper function called getNetExchange. Specifically its the conditional Object.keys(zoneData.exchange).length === 0 from this code block:
|
/** |
|
* Returns the net exchange of a zone |
|
* @param zoneData - The zone data |
|
* @returns The net exchange |
|
*/ |
|
export function getNetExchange( |
|
zoneData: ZoneDetail, |
|
displayByEmissions: boolean |
|
): number { |
|
if (Object.keys(zoneData.exchange).length === 0) { |
|
return Number.NaN; |
|
} |
By removing it, the bug resolves.
Why it's a bug
I consider it a bug currently because...
-
The function's name, getNetExchange, is a low-level helper function for getting a net exchange value from totalImport and totalExport (and CO2 equivalent values). Thus, it is surprising that it requires data about individual exchanges not used in its calculation.
-
The function getNetExchange is only used by the net exchange graph UI, which only affects that. The only outcome of the if statement is that the 30d+ views won't present the electric net exchange chart.
Click to expand a screenshot from a repo search for the function name

Bug description
Data (
totalExportandtotalImport) is available for an electric net exchange chart with 30d+ views, but it's only presented for the 24h and 72h views.There isn't data about
totalCo2ExportortotalCo2Import, so this issue is down-scoped to getting the electric net exchange chart to avoid addressing separate underlying problems. I've opened #7596 to address that.Click to expand electric net exchange chart screenshots
Analysis
The reason for 30d+ views not presenting the net exchange chart stems from a detail in a low-level helper function called
getNetExchange. Specifically its the conditionalObject.keys(zoneData.exchange).length === 0from this code block:electricitymaps-contrib/web/src/utils/helpers.ts
Lines 190 to 201 in c9a3a8f
By removing it, the bug resolves.
Why it's a bug
I consider it a bug currently because...
The function's name,
getNetExchange, is a low-level helper function for getting a net exchange value fromtotalImportandtotalExport(and CO2 equivalent values). Thus, it is surprising that it requires data about individual exchanges not used in its calculation.The function
getNetExchangeis only used by the net exchange graph UI, which only affects that. The only outcome of the if statement is that the 30d+ views won't present the electric net exchange chart.Click to expand a screenshot from a repo search for the function name