From 15b732dbffd8bbde6e7c63fb04ac14fdf4701cf4 Mon Sep 17 00:00:00 2001 From: Maschga <88616799+Maschga@users.noreply.github.com> Date: Wed, 19 Nov 2025 22:54:09 +0100 Subject: [PATCH] fix: forecast default to empty array (#25177) --- assets/js/components/Forecast/Chart.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/js/components/Forecast/Chart.vue b/assets/js/components/Forecast/Chart.vue index 50f21e81f..24b91a002 100644 --- a/assets/js/components/Forecast/Chart.vue +++ b/assets/js/components/Forecast/Chart.vue @@ -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