Data table compact hours 1h, 2h, 3h or 4h. Calc max/min or average
This commit is contained in:
fraxle
2026-06-02 23:31:14 +01:00
parent 7b603867dd
commit 5a03077d9e
5 changed files with 147 additions and 11 deletions
+17 -2
View File
@@ -30,7 +30,7 @@ import {
UTCI_ENVIRONMENTS, VARIANT_DEFAULT_ENV,
} from '../config.js';
import { utciCategory } from '../utils.js';
import { buildHourlyRows } from '../compute.js';
import { buildHourlyRows, aggregateRows } from '../compute.js';
import { useForecast } from './useForecast.js';
import { useColumnPopup } from './useColumnPopup.js';
import { useTableScroll } from './useTableScroll.js';
@@ -293,6 +293,16 @@ export function useAppState() {
return next;
});
// Table row interval: 1 = every hour (default), 2/3/4 = clock-aligned buckets.
const [tableInterval, setTableIntervalState] = useState(() => {
try { const n = parseInt(localStorage.getItem('sunscope_table_interval'), 10); return [1, 2, 3, 4].includes(n) ? n : 3; } catch (e) { return 3; }
});
const setTableInterval = (n) => setTableIntervalState(() => {
const next = [1, 2, 3, 4].includes(n) ? n : 1;
try { localStorage.setItem('sunscope_table_interval', String(next)); } catch (e) { /* ignore */ }
return next;
});
const searchTimeout = useRef(null);
// Derived selectors used by profile controls
@@ -404,6 +414,10 @@ export function useAppState() {
});
const visible = days[selectedDay]?.rows || [];
// Rows actually rendered in the table - bucketed by the interval selector.
// `visible` stays full-resolution so the dial, glance and event detection
// keep seeing every hour.
const tableRows = aggregateRows(visible, tableInterval);
const nowLocalISO = new Date(now.getTime() + utcOffsetMs).toISOString().slice(0, 13);
const currentRow = hourlyRows.length > 0
@@ -601,6 +615,7 @@ export function useAppState() {
utciEnv, setUtciEnv: setUtciEnvAndSave,
showDecimals, toggleShowDecimals,
showUnits, toggleShowUnits,
tableInterval, setTableInterval,
// table refs
headStickyRef, headTrackRef, headTableRef,
bodyScrollRef, bodyTableRef, tableWrapRef,
@@ -617,7 +632,7 @@ export function useAppState() {
tableCanScrollLeft, tableCanScrollRight, handleBodyScroll,
// computation
hourlyRows, days, utcOffsetMs,
visible, nowLocalISO, currentRow, currentCat,
visible, tableRows, nowLocalISO, currentRow, currentCat,
// banner + events
activeEvents, lensEvent, selectedDayEvents,
bannerIndex, bannerTransition, bannerPrevIndex,