From d899711a4835c5183990403afcb37217a4f2c6ad Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 5 Mar 2025 01:38:13 -0800 Subject: [PATCH] Remember hidden energy devices from storage (#24470) * Remember hidden devices from storage * remove accidental * typing fix --- src/components/chart/ha-chart-base.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/chart/ha-chart-base.ts b/src/components/chart/ha-chart-base.ts index b8dc5f59d5..2975610e9b 100644 --- a/src/components/chart/ha-chart-base.ts +++ b/src/components/chart/ha-chart-base.ts @@ -318,6 +318,16 @@ export class HaChartBase extends LitElement { } }); } + + const legend = ensureArray(this.options?.legend || [])[0] as + | LegendComponentOption + | undefined; + Object.entries(legend?.selected || {}).forEach(([stat, selected]) => { + if (selected === false) { + this._hiddenDatasets.add(stat); + } + }); + this.chart.setOption({ ...this._createOptions(), series: this._getSeries(),