- data-pipeline: hourly NDW snapshot job (occupancy + status) + GitHub Action; per-gemeente day files, current-status, daily-average rollup. - webapp: usage-over-day chart in detail panel; fresh per-gemeente status colours; national analysis choropleth (LayerSwitcher) + gemeente scorecard with demand (peer-model), siting priority, congestion and live/potential net-impact scenario. - analysis/ (Python): golden dataset (CBS Kerncijfers + chargers) -> derived metrics + models (demand, siting, congestion, municipal percentiles). - UX: InfoTip tooltips throughout, expanded methodology modal, interactive guided tour (spotlight + blur) that drives the app to example screens. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
// Sequential color ramp (YlOrRd-ish) for choropleths.
|
|
export type RGBA = [number, number, number, number];
|
|
|
|
const STOPS: [number, number, number][] = [
|
|
[255, 255, 204],
|
|
[254, 217, 118],
|
|
[253, 141, 60],
|
|
[240, 59, 32],
|
|
[189, 0, 38],
|
|
];
|
|
|
|
export const NODATA: RGBA = [226, 232, 240, 120]; // slate-200, translucent
|
|
|
|
export function rampColor(t: number, alpha = 200): RGBA {
|
|
const x = Math.min(1, Math.max(0, t));
|
|
const seg = x * (STOPS.length - 1);
|
|
const i = Math.min(STOPS.length - 2, Math.floor(seg));
|
|
const f = seg - i;
|
|
const a = STOPS[i];
|
|
const b = STOPS[i + 1];
|
|
return [
|
|
Math.round(a[0] + (b[0] - a[0]) * f),
|
|
Math.round(a[1] + (b[1] - a[1]) * f),
|
|
Math.round(a[2] + (b[2] - a[2]) * f),
|
|
alpha,
|
|
];
|
|
}
|
|
|
|
export function rampCss(t: number): string {
|
|
const [r, g, b] = rampColor(t, 255);
|
|
return `rgb(${r},${g},${b})`;
|
|
}
|
|
|
|
// Robust domain [p5, p95] over numeric values.
|
|
export function robustDomain(values: number[]): [number, number] {
|
|
const v = values.filter((x) => Number.isFinite(x)).sort((a, b) => a - b);
|
|
if (v.length === 0) return [0, 1];
|
|
const at = (p: number) => v[Math.min(v.length - 1, Math.max(0, Math.floor(p * (v.length - 1))))];
|
|
const lo = at(0.05);
|
|
const hi = at(0.95);
|
|
return hi > lo ? [lo, hi] : [v[0], v[v.length - 1] || v[0] + 1];
|
|
}
|