mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
FIx device graph not rendering right when changing period (#9806)
This commit is contained in:
parent
3a112531cc
commit
4a4465efb6
@ -243,9 +243,19 @@ export default class HaChartBase extends LitElement {
|
||||
};
|
||||
}
|
||||
|
||||
public updateChart = (): void => {
|
||||
public updateChart = (
|
||||
mode:
|
||||
| "resize"
|
||||
| "reset"
|
||||
| "none"
|
||||
| "hide"
|
||||
| "show"
|
||||
| "normal"
|
||||
| "active"
|
||||
| undefined
|
||||
): void => {
|
||||
if (this.chart) {
|
||||
this.chart.update();
|
||||
this.chart.update(mode);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,7 @@ import { getRelativePosition } from "chart.js/helpers";
|
||||
import { addHours } from "date-fns";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { getColorByIndex } from "../../../../common/color/colors";
|
||||
@ -19,6 +19,7 @@ import {
|
||||
numberFormatToLocale,
|
||||
} from "../../../../common/string/format_number";
|
||||
import "../../../../components/chart/ha-chart-base";
|
||||
import type HaChartBase from "../../../../components/chart/ha-chart-base";
|
||||
import "../../../../components/ha-card";
|
||||
import { EnergyData, getEnergyDataCollection } from "../../../../data/energy";
|
||||
import {
|
||||
@ -45,6 +46,8 @@ export class HuiEnergyDevicesGraphCard
|
||||
|
||||
@state() private _chartData: ChartData = { datasets: [] };
|
||||
|
||||
@query("ha-chart-base") private _chart?: HaChartBase;
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
return [
|
||||
getEnergyDataCollection(this.hass, {
|
||||
@ -207,6 +210,8 @@ export class HuiEnergyDevicesGraphCard
|
||||
this._chartData = {
|
||||
datasets,
|
||||
};
|
||||
await this.updateComplete;
|
||||
this._chart?.updateChart("none");
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
Loading…
x
Reference in New Issue
Block a user