From 34e1d745beb7001e13863d436fe6b9881faf1508 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Thu, 8 Dec 2022 11:34:13 +0100 Subject: [PATCH] Restore correct default legend behavior for history graph card (#14612) fixes undefined --- src/components/chart/state-history-chart-line.ts | 2 +- src/components/chart/state-history-chart-timeline.ts | 6 +++++- src/panels/lovelace/cards/hui-history-graph-card.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/chart/state-history-chart-line.ts b/src/components/chart/state-history-chart-line.ts index 488fc9ee58..95f52185fc 100644 --- a/src/components/chart/state-history-chart-line.ts +++ b/src/components/chart/state-history-chart-line.ts @@ -47,7 +47,7 @@ class StateHistoryChartLine extends LitElement { } public willUpdate(changedProps: PropertyValues) { - if (!this.hasUpdated) { + if (!this.hasUpdated || changedProps.has("showNames")) { this._chartOptions = { parsing: false, animation: false, diff --git a/src/components/chart/state-history-chart-timeline.ts b/src/components/chart/state-history-chart-timeline.ts index 3425ccbd6a..ac8de6813b 100644 --- a/src/components/chart/state-history-chart-timeline.ts +++ b/src/components/chart/state-history-chart-timeline.ts @@ -64,7 +64,11 @@ export class StateHistoryChartTimeline extends LitElement { this._generateData(); } - if (changedProps.has("startTime") || changedProps.has("endTime")) { + if ( + changedProps.has("startTime") || + changedProps.has("endTime") || + changedProps.has("showNames") + ) { this._createOptions(); } } diff --git a/src/panels/lovelace/cards/hui-history-graph-card.ts b/src/panels/lovelace/cards/hui-history-graph-card.ts index eda1fa1239..c18864e4b3 100644 --- a/src/panels/lovelace/cards/hui-history-graph-card.ts +++ b/src/panels/lovelace/cards/hui-history-graph-card.ts @@ -144,7 +144,9 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard { .historyData=${this._stateHistory} .names=${this._names} up-to-now - .showNames=${this._config.show_names} + .showNames=${this._config.show_names !== undefined + ? this._config.show_names + : true} >