mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-28 15:27:20 +00:00
Fix statistics graph (#9607)
This commit is contained in:
parent
586fa1d0f0
commit
f459abdf85
@ -267,7 +267,12 @@ class StatisticsChart extends LitElement {
|
|||||||
stats.forEach((stat) => {
|
stats.forEach((stat) => {
|
||||||
const dataValues: Array<number | null> = [];
|
const dataValues: Array<number | null> = [];
|
||||||
statTypes.forEach((type) => {
|
statTypes.forEach((type) => {
|
||||||
const val = stat[type];
|
let val: number | null;
|
||||||
|
if (type === "sum") {
|
||||||
|
val = stat.state;
|
||||||
|
} else {
|
||||||
|
val = stat[type];
|
||||||
|
}
|
||||||
dataValues.push(val !== null ? Math.round(val * 100) / 100 : null);
|
dataValues.push(val !== null ? Math.round(val * 100) / 100 : null);
|
||||||
});
|
});
|
||||||
const date = new Date(stat.start);
|
const date = new Date(stat.start);
|
||||||
|
@ -146,7 +146,10 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const startDate = new Date();
|
const startDate = new Date();
|
||||||
startDate.setHours(-24 * (this._config!.days_to_show || 30));
|
startDate.setTime(
|
||||||
|
startDate.getTime() -
|
||||||
|
1000 * 60 * 60 * (24 * (this._config!.days_to_show || 30) + 1)
|
||||||
|
);
|
||||||
this._fetching = true;
|
this._fetching = true;
|
||||||
try {
|
try {
|
||||||
this._statistics = await fetchStatistics(
|
this._statistics = await fetchStatistics(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user