mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix showing a statistics graph with type 'change' (#14622)
This commit is contained in:
parent
3b51050b52
commit
d1b1eecd92
@ -32,7 +32,7 @@ import {
|
|||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import "./ha-chart-base";
|
import "./ha-chart-base";
|
||||||
|
|
||||||
export type ExtendedStatisticType = StatisticType | "state" | "change";
|
export type ExtendedStatisticType = StatisticType | "change";
|
||||||
|
|
||||||
export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
||||||
mean: "mean",
|
mean: "mean",
|
||||||
|
@ -9,7 +9,10 @@ import {
|
|||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import "../../../components/chart/statistics-chart";
|
import {
|
||||||
|
ExtendedStatisticType,
|
||||||
|
statTypeMap,
|
||||||
|
} from "../../../components/chart/statistics-chart";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import {
|
import {
|
||||||
fetchStatistics,
|
fetchStatistics,
|
||||||
@ -17,7 +20,6 @@ import {
|
|||||||
getStatisticMetadata,
|
getStatisticMetadata,
|
||||||
Statistics,
|
Statistics,
|
||||||
StatisticsMetaData,
|
StatisticsMetaData,
|
||||||
StatisticsTypes,
|
|
||||||
} from "../../../data/recorder";
|
} from "../../../data/recorder";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
@ -70,7 +72,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _interval?: number;
|
private _interval?: number;
|
||||||
|
|
||||||
private _statTypes?: StatisticsTypes;
|
private _statTypes?: Array<ExtendedStatisticType>;
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
@ -249,7 +251,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this._entities,
|
this._entities,
|
||||||
this._config!.period,
|
this._config!.period,
|
||||||
unitconfig,
|
unitconfig,
|
||||||
this._statTypes
|
this._statTypes?.map((stat_type) => statTypeMap[stat_type])
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this._statistics = undefined;
|
this._statistics = undefined;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Statistic, StatisticType } from "../../../data/recorder";
|
import { Statistic } from "../../../data/recorder";
|
||||||
import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace";
|
import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace";
|
||||||
import { FullCalendarView, TranslationDict } from "../../../types";
|
import { FullCalendarView, TranslationDict } from "../../../types";
|
||||||
import { Condition } from "../common/validate-condition";
|
import { Condition } from "../common/validate-condition";
|
||||||
@ -10,6 +10,7 @@ import {
|
|||||||
LovelaceRowConfig,
|
LovelaceRowConfig,
|
||||||
} from "../entity-rows/types";
|
} from "../entity-rows/types";
|
||||||
import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||||
|
import { ExtendedStatisticType } from "../../../components/chart/statistics-chart";
|
||||||
import { HaDurationData } from "../../../components/ha-duration-input";
|
import { HaDurationData } from "../../../components/ha-duration-input";
|
||||||
import { LovelaceTileFeatureConfig } from "../tile-features/types";
|
import { LovelaceTileFeatureConfig } from "../tile-features/types";
|
||||||
|
|
||||||
@ -309,7 +310,7 @@ export interface StatisticsGraphCardConfig extends LovelaceCardConfig {
|
|||||||
unit?: string;
|
unit?: string;
|
||||||
days_to_show?: number;
|
days_to_show?: number;
|
||||||
period?: "5minute" | "hour" | "day" | "month";
|
period?: "5minute" | "hour" | "day" | "month";
|
||||||
stat_types?: StatisticType | StatisticType[];
|
stat_types?: ExtendedStatisticType | ExtendedStatisticType[];
|
||||||
chart_type?: "line" | "bar";
|
chart_type?: "line" | "bar";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user