From 0358c58e04a6c8344250454c2bac6e434425dc9f Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:00:17 +0000 Subject: [PATCH] Cleanly handle unavailable entities --- src/elec-sankey.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/elec-sankey.ts b/src/elec-sankey.ts index 0b29b68..1528d64 100644 --- a/src/elec-sankey.ts +++ b/src/elec-sankey.ts @@ -580,10 +580,11 @@ export class ElecSankey extends LitElement { const divArray: TemplateResult[] = []; const startTerminatorY = 0; - + let phantomRate = 0; const routes = structuredClone(this.generationInRoutes); if (this._phantomGenerationInRoute !== undefined) { routes.phantom = this._phantomGenerationInRoute; + phantomRate = this._phantomGenerationInRoute.rate; } let i = 0; // eslint-disable-next-line guard-for-in @@ -591,10 +592,10 @@ export class ElecSankey extends LitElement { if (Object.prototype.hasOwnProperty.call(routes, key)) { // const friendlyName = routes.text; let width = 0; - const rate = routes[key].rate; + const rate = routes[key].rate || 0; // Handle undefined (NaN) rates. // Most of the time, if the rate is zero, we don't want to draw it. - // Exception is if we have > phantom source. - if (rate || routes.phantom.rate > 0) { + // Exception is if we have a >0 phantom source. + if (rate || phantomRate > 0) { width = this._rateToWidth(rate); svgArray.push( renderFlowByCorners(