From b53c73f0c8ad0f23d5aaf1a3946b7749e65b00bd Mon Sep 17 00:00:00 2001 From: Olivier Corradi <1655848+corradio@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:31:10 +0100 Subject: [PATCH] Add exports+storage to origin charts (#7571) * Add exports+storage to origin charts * Update web/src/features/charts/elements/AreaGraphLayers.tsx * Update web/src/features/charts/elements/AreaGraphLayers.tsx --- web/src/features/charts/elements/AreaGraphLayers.tsx | 11 ++++++++++- web/src/features/charts/hooks/useOriginChartData.ts | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/web/src/features/charts/elements/AreaGraphLayers.tsx b/web/src/features/charts/elements/AreaGraphLayers.tsx index 2a81467f36..e3e42a6161 100644 --- a/web/src/features/charts/elements/AreaGraphLayers.tsx +++ b/web/src/features/charts/elements/AreaGraphLayers.tsx @@ -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; diff --git a/web/src/features/charts/hooks/useOriginChartData.ts b/web/src/features/charts/hooks/useOriginChartData.ts index 7f9863dc90..dd8454389c 100644 --- a/web/src/features/charts/hooks/useOriginChartData.ts +++ b/web/src/features/charts/hooks/useOriginChartData.ts @@ -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] = @@ -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