fix: forecast default to empty array (#25177)

This commit is contained in:
Maschga 2025-11-19 22:54:09 +01:00 • committed by GitHub
parent 522caa36bc
commit 15b732dbff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -163,7 +163,7 @@ export default defineComponent({
order: active ? 0 : 1,
});
}
if (this.gridSlots.length > 0) {
if (this.gridSlots && this.gridSlots.length > 0) {
const active = this.selected === ForecastType.Price;
const color = active ? colors.price : colors.border;
datasets.push({
@ -184,7 +184,7 @@ export default defineComponent({
order: active ? 0 : 1,
});
}
if (this.co2Slots.length > 0) {
if (this.co2Slots && this.co2Slots.length > 0) {
const active = this.selected === ForecastType.Co2;
const color = active ? colors.co2 : colors.border;
datasets.push({
@ -427,6 +427,10 @@ export default defineComponent({
this.startDate = now;
},
filterSlots(slots: ForecastSlot[] = []) {
if (!slots) {
return undefined;
}
return slots.filter(
(slot) =>
new Date(slot.end) >= this.startDate && new Date(slot.start) <= this.endDate