Bring back energy usage graph order (#24156)

This commit is contained in:
Petar Petrov 2025-02-10 16:53:36 +02:00 committed by GitHub
parent a26bf80b13
commit 3d5c65d652
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -300,6 +300,8 @@ export class HuiEnergyUsageGraphCard
type: "bar", type: "bar",
stack: "usage", stack: "usage",
data: [], data: [],
// @ts-expect-error
order: 0,
}); });
} }
@ -315,6 +317,8 @@ export class HuiEnergyUsageGraphCard
) )
); );
// @ts-expect-error
datasets.sort((a, b) => a.order - b.order);
fillDataGapsAndRoundCaps(datasets); fillDataGapsAndRoundCaps(datasets);
this._chartData = datasets; this._chartData = datasets;
} }
@ -482,7 +486,7 @@ export class HuiEnergyUsageGraphCard
this._compareStart! this._compareStart!
); );
Object.entries(combinedData).forEach(([type, sources]) => { Object.entries(combinedData).forEach(([type, sources], idx) => {
Object.entries(sources).forEach(([statId, source]) => { Object.entries(sources).forEach(([statId, source]) => {
const points: BarSeriesOption["data"] = []; const points: BarSeriesOption["data"] = [];
// Process chart data. // Process chart data.
@ -513,6 +517,13 @@ export class HuiEnergyUsageGraphCard
statId, statId,
statisticsMetaData[statId] statisticsMetaData[statId]
), ),
// @ts-expect-error
order:
type === "used_solar"
? 1
: type === "to_battery"
? Object.keys(combinedData).length
: idx + 2,
barMaxWidth: 50, barMaxWidth: 50,
itemStyle: { itemStyle: {
borderColor: getEnergyColor( borderColor: getEnergyColor(