Fix too wide energy chart bars (#17787)

This commit is contained in:
karwosts 2023-09-26 13:49:04 -07:00 committed by GitHub
parent 965f893a65
commit 01405d96b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 0 deletions

View File

@ -378,6 +378,7 @@ export class HuiEnergyGasGraphCard
// Process gas consumption data. // Process gas consumption data.
if (source.stat_energy_from in statistics) { if (source.stat_energy_from in statistics) {
const stats = statistics[source.stat_energy_from]; const stats = statistics[source.stat_energy_from];
let end;
for (const point of stats) { for (const point of stats) {
if (point.change === null || point.change === undefined) { if (point.change === null || point.change === undefined) {
@ -392,6 +393,13 @@ export class HuiEnergyGasGraphCard
y: point.change, y: point.change,
}); });
prevStart = point.start; prevStart = point.start;
end = point.end;
}
if (gasConsumptionData.length === 1) {
gasConsumptionData.push({
x: end,
y: 0,
});
} }
} }

View File

@ -401,6 +401,7 @@ export class HuiEnergySolarGraphCard
// Process solar production data. // Process solar production data.
if (source.stat_energy_from in statistics) { if (source.stat_energy_from in statistics) {
const stats = statistics[source.stat_energy_from]; const stats = statistics[source.stat_energy_from];
let end;
for (const point of stats) { for (const point of stats) {
if (point.change === null || point.change === undefined) { if (point.change === null || point.change === undefined) {
@ -415,6 +416,13 @@ export class HuiEnergySolarGraphCard
y: point.change, y: point.change,
}); });
prevStart = point.start; prevStart = point.start;
end = point.end;
}
if (solarProductionData.length === 1) {
solarProductionData.push({
x: end,
y: 0,
});
} }
} }

View File

@ -523,6 +523,7 @@ export class HuiEnergyUsageGraphCard
solar?: { [start: number]: number }; solar?: { [start: number]: number };
} = {}; } = {};
let pointEndTime;
Object.entries(statIdsByCat).forEach(([key, statIds]) => { Object.entries(statIdsByCat).forEach(([key, statIds]) => {
const sum = [ const sum = [
"solar", "solar",
@ -550,9 +551,11 @@ export class HuiEnergyUsageGraphCard
if (sum) { if (sum) {
totalStats[stat.start] = totalStats[stat.start] =
stat.start in totalStats ? totalStats[stat.start] + val : val; stat.start in totalStats ? totalStats[stat.start] + val : val;
pointEndTime = stat.end;
} }
if (add && !(stat.start in set)) { if (add && !(stat.start in set)) {
set[stat.start] = val; set[stat.start] = val;
pointEndTime = stat.end;
} }
}); });
sets[id] = set; sets[id] = set;
@ -670,6 +673,12 @@ export class HuiEnergyUsageGraphCard
: value, : value,
}); });
} }
if (points.length === 1) {
points.push({
x: pointEndTime,
y: 0,
});
}
data.push({ data.push({
label: label:

View File

@ -376,6 +376,7 @@ export class HuiEnergyWaterGraphCard
// Process water consumption data. // Process water consumption data.
if (source.stat_energy_from in statistics) { if (source.stat_energy_from in statistics) {
const stats = statistics[source.stat_energy_from]; const stats = statistics[source.stat_energy_from];
let end;
for (const point of stats) { for (const point of stats) {
if (point.change === null || point.change === undefined) { if (point.change === null || point.change === undefined) {
@ -390,6 +391,13 @@ export class HuiEnergyWaterGraphCard
y: point.change, y: point.change,
}); });
prevStart = point.start; prevStart = point.start;
end = point.end;
}
if (waterConsumptionData.length === 1) {
waterConsumptionData.push({
x: end,
y: 0,
});
} }
} }