Skip to content

Commit

Permalink
Add exports+storage to origin charts (#7571)
Browse files Browse the repository at this point in the history
* Add exports+storage to origin charts

* Update web/src/features/charts/elements/AreaGraphLayers.tsx

* Update web/src/features/charts/elements/AreaGraphLayers.tsx
  • Loading branch information
corradio authored Dec 18, 2024
1 parent aada3b9 commit b53c73f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion web/src/features/charts/elements/AreaGraphLayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ function AreaGraphLayers({
.x((d: any) => timeScale(d.data.datetime))
.y0((d) => valueScale(d[0]))
.y1((d) => valueScale(d[1]))
.defined((d) => (shouldHideEmptyData ? d[1] > 0 : Number.isFinite(d[1])));
.defined((d) => {
if (!Number.isFinite(d[0]) || !Number.isFinite(d[1])) {
return false;
}
if (shouldHideEmptyData && d[0] == d[1]) {
// zero area height
return false;
}
return true;
});

// Mouse hover events
let mouseOutTimeout: string | number | NodeJS.Timeout | undefined;
Expand Down
4 changes: 2 additions & 2 deletions web/src/features/charts/hooks/useOriginChartData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function useOriginChartData() {
// Add exchanges
for (const [key, exchangeValue] of Object.entries(value.exchange)) {
// in GW or MW
entry.layerData[key] = Math.max(0, exchangeValue / valueFactor);
entry.layerData[key] = exchangeValue / valueFactor;
if (displayByEmissions) {
// in gCO₂eq/hour
entry.layerData[key] =
Expand Down Expand Up @@ -143,7 +143,7 @@ function getStorageValue(
return Number.NaN;
}

const invertedValue = -1 * Math.min(0, storageValue);
const invertedValue = -1 * storageValue;

return displayByEmissions
? invertedValue * value.dischargeCo2Intensities[storageKey] * valueFactor
Expand Down

0 comments on commit b53c73f

Please sign in to comment.