fix history graph configuration timeline update (#14101)

This commit is contained in:
Travis Collins 2022-10-17 10:02:11 -06:00 committed by GitHub
parent dec8883f2a
commit 23f8373b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,6 +118,25 @@ export class StateHistoryChartTimeline extends LitElement {
public willUpdate(changedProps: PropertyValues) {
if (!this.hasUpdated) {
this._createOptions();
}
if (
changedProps.has("data") ||
this._chartTime <
new Date(this.endTime.getTime() - MIN_TIME_BETWEEN_UPDATES)
) {
// If the line is more than 5 minutes old, re-gen it
// so the X axis grows even if there is no new data
this._generateData();
}
if (changedProps.has("startTime") || changedProps.has("endTime")) {
this._createOptions();
}
}
private _createOptions() {
const narrow = this.narrow;
this._chartOptions = {
maintainAspectRatio: false,
@ -213,16 +232,6 @@ export class StateHistoryChartTimeline extends LitElement {
locale: numberFormatToLocale(this.hass.locale),
};
}
if (
changedProps.has("data") ||
this._chartTime <
new Date(this.endTime.getTime() - MIN_TIME_BETWEEN_UPDATES)
) {
// If the line is more than 5 minutes old, re-gen it
// so the X axis grows even if there is no new data
this._generateData();
}
}
private _generateData() {
const computedStyles = getComputedStyle(this);