Skip to content

Commit 9e4fe3f

Browse files
committed
Hide today's row from weather chart past local noon
By midday today's entry has already played out — actual conditions diverge from forecast and the live SolisBox covers the PV side. Filter the day out of the chart entirely once the local clock passes 12:00 so the chart focuses on the genuinely forward-looking forecast.
1 parent 3b020fa commit 9e4fe3f

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

‎frontend/src/components/FmiWeatherBox.tsx‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ const WeatherBox: React.FC<WeatherBoxProps> = ({ className }) => {
8080
// Aggregate hourly PV forecast points to per-day kWh + hour count.
8181
// Days with partial coverage (e.g. first/last day of the 66h window) are
8282
// dropped from the chart to avoid showing misleading near-zero totals.
83+
// Today's forecast is also dropped past local noon: by midday actual
84+
// generation has eclipsed the forecast and the SolisBox already shows
85+
// the live number, making the forward-looking bar redundant.
8386
const FULL_DAY_HOURS = 20;
87+
const HIDE_TODAY_PAST_HOUR = 12;
8488
const pvByDate = new Map<string, { kwh: number; hours: number }>();
8589
for (const p of pvForecast?.points ?? []) {
8690
const key = p.time.slice(0, 10);
@@ -91,18 +95,25 @@ const WeatherBox: React.FC<WeatherBoxProps> = ({ className }) => {
9195
});
9296
}
9397

94-
const chartData = daily.map((d) => {
95-
const key = d.date.slice(0, 10);
96-
const pv = pvByDate.get(key);
97-
return {
98-
temp: d.temperatureMax,
99-
rain: d.precipitation,
100-
pvKwh: pv && pv.hours >= FULL_DAY_HOURS ? pv.kwh : null,
101-
label: `${format(new Date(d.date), "EEEEEE", {
102-
locale: fi,
103-
})}`,
104-
};
105-
});
98+
const nowDate = new Date();
99+
const todayKey = format(nowDate, "yyyy-MM-dd");
100+
const hideToday = nowDate.getHours() >= HIDE_TODAY_PAST_HOUR;
101+
102+
const chartData = daily
103+
.filter((d) => !(d.date.slice(0, 10) === todayKey && hideToday))
104+
.map((d) => {
105+
const key = d.date.slice(0, 10);
106+
const pv = pvByDate.get(key);
107+
const includePv = pv && pv.hours >= FULL_DAY_HOURS;
108+
return {
109+
temp: d.temperatureMax,
110+
rain: d.precipitation,
111+
pvKwh: includePv ? pv.kwh : null,
112+
label: `${format(new Date(d.date), "EEEEEE", {
113+
locale: fi,
114+
})}`,
115+
};
116+
});
106117

107118
const segments = getFmiTemperatureSegments(hourly);
108119

0 commit comments

Comments
 (0)