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 const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
||||
export const supportedStatTypeMap: Record<
|
||||
ExtendedStatisticType,
|
||||
StatisticType
|
||||
> = {
|
||||
mean: "mean",
|
||||
min: "min",
|
||||
max: "max",
|
||||
|
@ -43,6 +46,15 @@ export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
|||
change: "sum",
|
||||
};
|
||||
|
||||
export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
||||
mean: "mean",
|
||||
min: "min",
|
||||
max: "max",
|
||||
sum: "sum",
|
||||
state: "state",
|
||||
change: "sum",
|
||||
};
|
||||
|
||||
@customElement("statistics-chart")
|
||||
class StatisticsChart extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
|
|
@ -154,7 +154,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||
|
||||
if (
|
||||
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?.period !== this._config.period ||
|
||||
oldConfig?.unit !== this._config.unit)
|
||||
|
|
|
@ -26,6 +26,7 @@ import { deepEqual } from "../../../../common/util/deep-equal";
|
|||
import {
|
||||
ExtendedStatisticType,
|
||||
statTypeMap,
|
||||
supportedStatTypeMap,
|
||||
} from "../../../../components/chart/statistics-chart";
|
||||
import "../../../../components/entity/ha-statistics-picker";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
|
@ -185,7 +186,10 @@ export class HuiStatisticsGraphCardEditor
|
|||
disabled:
|
||||
!metaDatas ||
|
||||
!metaDatas.every((metaData) =>
|
||||
statisticsMetaHasType(metaData, statTypeMap[stat_type])
|
||||
statisticsMetaHasType(
|
||||
metaData,
|
||||
supportedStatTypeMap[stat_type]
|
||||
)
|
||||
),
|
||||
})),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue