mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix statistics graph card (#14631)
This commit is contained in:
parent
ba09120ff3
commit
8c69c772d1
@ -34,7 +34,10 @@ import "./ha-chart-base";
|
|||||||
|
|
||||||
export type ExtendedStatisticType = StatisticType | "change";
|
export type ExtendedStatisticType = StatisticType | "change";
|
||||||
|
|
||||||
export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
export const supportedStatTypeMap: Record<
|
||||||
|
ExtendedStatisticType,
|
||||||
|
StatisticType
|
||||||
|
> = {
|
||||||
mean: "mean",
|
mean: "mean",
|
||||||
min: "min",
|
min: "min",
|
||||||
max: "max",
|
max: "max",
|
||||||
@ -43,6 +46,15 @@ export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
|||||||
change: "sum",
|
change: "sum",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
||||||
|
mean: "mean",
|
||||||
|
min: "min",
|
||||||
|
max: "max",
|
||||||
|
sum: "sum",
|
||||||
|
state: "state",
|
||||||
|
change: "sum",
|
||||||
|
};
|
||||||
|
|
||||||
@customElement("statistics-chart")
|
@customElement("statistics-chart")
|
||||||
class StatisticsChart extends LitElement {
|
class StatisticsChart extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
@ -154,7 +154,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
changedProps.has("_config") &&
|
changedProps.has("_config") &&
|
||||||
(oldConfig?.entities !== this._config.entities ||
|
(oldConfig?.stat_types !== this._config.stat_types ||
|
||||||
oldConfig?.days_to_show !== this._config.days_to_show ||
|
oldConfig?.days_to_show !== this._config.days_to_show ||
|
||||||
oldConfig?.period !== this._config.period ||
|
oldConfig?.period !== this._config.period ||
|
||||||
oldConfig?.unit !== this._config.unit)
|
oldConfig?.unit !== this._config.unit)
|
||||||
|
@ -26,6 +26,7 @@ import { deepEqual } from "../../../../common/util/deep-equal";
|
|||||||
import {
|
import {
|
||||||
ExtendedStatisticType,
|
ExtendedStatisticType,
|
||||||
statTypeMap,
|
statTypeMap,
|
||||||
|
supportedStatTypeMap,
|
||||||
} from "../../../../components/chart/statistics-chart";
|
} from "../../../../components/chart/statistics-chart";
|
||||||
import "../../../../components/entity/ha-statistics-picker";
|
import "../../../../components/entity/ha-statistics-picker";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
@ -185,7 +186,10 @@ export class HuiStatisticsGraphCardEditor
|
|||||||
disabled:
|
disabled:
|
||||||
!metaDatas ||
|
!metaDatas ||
|
||||||
!metaDatas.every((metaData) =>
|
!metaDatas.every((metaData) =>
|
||||||
statisticsMetaHasType(metaData, statTypeMap[stat_type])
|
statisticsMetaHasType(
|
||||||
|
metaData,
|
||||||
|
supportedStatTypeMap[stat_type]
|
||||||
|
)
|
||||||
),
|
),
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user