mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-05 07:27:47 +00:00
redraw
This commit is contained in:
parent
c1e905e03a
commit
36710d7588
@ -50,6 +50,8 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _error?: string;
|
private _error?: string;
|
||||||
|
|
||||||
|
private _interval?: number;
|
||||||
|
|
||||||
private _subscribed?: Promise<(() => Promise<void>) | void>;
|
private _subscribed?: Promise<(() => Promise<void>) | void>;
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
@ -97,7 +99,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _subscribeHistoryWindow() {
|
private _subscribeHistoryWindow() {
|
||||||
if (this._subscribed) {
|
if (this._subscribed) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
this._subscribed = subscribeHistoryStatesWindow(
|
this._subscribed = subscribeHistoryStatesWindow(
|
||||||
this.hass!,
|
this.hass!,
|
||||||
@ -118,13 +120,26 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this._subscribed = undefined;
|
this._subscribed = undefined;
|
||||||
this._error = err;
|
this._error = err;
|
||||||
});
|
});
|
||||||
return true;
|
this._setRedrawTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _redrawGraph() {
|
||||||
|
if (this._stateHistory) {
|
||||||
|
this._stateHistory = { ...this._stateHistory };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _setRedrawTimer() {
|
||||||
|
// redraw the graph every minute to update the time axis
|
||||||
|
clearInterval(this._interval);
|
||||||
|
this._interval = window.setInterval(() => this._redrawGraph(), 1000 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _unsubscribeHistoryWindow() {
|
private _unsubscribeHistoryWindow() {
|
||||||
if (!this._subscribed) {
|
if (!this._subscribed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
clearInterval(this._interval);
|
||||||
this._subscribed.then((unsubscribe) => {
|
this._subscribed.then((unsubscribe) => {
|
||||||
if (unsubscribe) {
|
if (unsubscribe) {
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user