mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47: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) => {
|
||||
const dataValues: Array<number | null> = [];
|
||||
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);
|
||||
});
|
||||
const date = new Date(stat.start);
|
||||
|
@ -146,7 +146,10 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
||||
return;
|
||||
}
|
||||
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;
|
||||
try {
|
||||
this._statistics = await fetchStatistics(
|
||||
|
Loading…
x
Reference in New Issue
Block a user