mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Fix too wide energy chart bars (#17787)
This commit is contained in:
parent
965f893a65
commit
01405d96b6
@ -378,6 +378,7 @@ export class HuiEnergyGasGraphCard
|
||||
// Process gas consumption data.
|
||||
if (source.stat_energy_from in statistics) {
|
||||
const stats = statistics[source.stat_energy_from];
|
||||
let end;
|
||||
|
||||
for (const point of stats) {
|
||||
if (point.change === null || point.change === undefined) {
|
||||
@ -392,6 +393,13 @@ export class HuiEnergyGasGraphCard
|
||||
y: point.change,
|
||||
});
|
||||
prevStart = point.start;
|
||||
end = point.end;
|
||||
}
|
||||
if (gasConsumptionData.length === 1) {
|
||||
gasConsumptionData.push({
|
||||
x: end,
|
||||
y: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,6 +401,7 @@ export class HuiEnergySolarGraphCard
|
||||
// Process solar production data.
|
||||
if (source.stat_energy_from in statistics) {
|
||||
const stats = statistics[source.stat_energy_from];
|
||||
let end;
|
||||
|
||||
for (const point of stats) {
|
||||
if (point.change === null || point.change === undefined) {
|
||||
@ -415,6 +416,13 @@ export class HuiEnergySolarGraphCard
|
||||
y: point.change,
|
||||
});
|
||||
prevStart = point.start;
|
||||
end = point.end;
|
||||
}
|
||||
if (solarProductionData.length === 1) {
|
||||
solarProductionData.push({
|
||||
x: end,
|
||||
y: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -523,6 +523,7 @@ export class HuiEnergyUsageGraphCard
|
||||
solar?: { [start: number]: number };
|
||||
} = {};
|
||||
|
||||
let pointEndTime;
|
||||
Object.entries(statIdsByCat).forEach(([key, statIds]) => {
|
||||
const sum = [
|
||||
"solar",
|
||||
@ -550,9 +551,11 @@ export class HuiEnergyUsageGraphCard
|
||||
if (sum) {
|
||||
totalStats[stat.start] =
|
||||
stat.start in totalStats ? totalStats[stat.start] + val : val;
|
||||
pointEndTime = stat.end;
|
||||
}
|
||||
if (add && !(stat.start in set)) {
|
||||
set[stat.start] = val;
|
||||
pointEndTime = stat.end;
|
||||
}
|
||||
});
|
||||
sets[id] = set;
|
||||
@ -670,6 +673,12 @@ export class HuiEnergyUsageGraphCard
|
||||
: value,
|
||||
});
|
||||
}
|
||||
if (points.length === 1) {
|
||||
points.push({
|
||||
x: pointEndTime,
|
||||
y: 0,
|
||||
});
|
||||
}
|
||||
|
||||
data.push({
|
||||
label:
|
||||
|
@ -376,6 +376,7 @@ export class HuiEnergyWaterGraphCard
|
||||
// Process water consumption data.
|
||||
if (source.stat_energy_from in statistics) {
|
||||
const stats = statistics[source.stat_energy_from];
|
||||
let end;
|
||||
|
||||
for (const point of stats) {
|
||||
if (point.change === null || point.change === undefined) {
|
||||
@ -390,6 +391,13 @@ export class HuiEnergyWaterGraphCard
|
||||
y: point.change,
|
||||
});
|
||||
prevStart = point.start;
|
||||
end = point.end;
|
||||
}
|
||||
if (waterConsumptionData.length === 1) {
|
||||
waterConsumptionData.push({
|
||||
x: end,
|
||||
y: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user