/** * Population history for the selected server. * * One inline SVG, no charting library: a min–max band, an average line, and a * range switcher. The paths come from `lib/chart.ts`, which is pure and tested. */ import { historyLoading, historyRange, historySeries, setHistoryRange } from "../lib/state"; import { buildChart } from "../lib/chart"; import { HISTORY_RANGES } from "../lib/types"; /** Drawing box. `preserveAspectRatio="none"` stretches it to the panel width. */ const WIDTH = 300; const HEIGHT = 56; export function HistoryChart() { const series = historySeries.value; const loading = historyLoading.value; const range = historyRange.value; const geometry = series ? buildChart(series.points, WIDTH, HEIGHT) : null; return (
Population
{HISTORY_RANGES.map((option) => ( ))}
{geometry ? ( <> {/* Band first so the average line sits on top of it. */} {/* non-scaling-stroke keeps the line 1px despite the stretched viewBox. */}
peak {geometry.peak} avg {geometry.mean} low {geometry.low} {geometry.cap > 0 && of {geometry.cap}} {series?.bucket} buckets
) : (

{loading ? "Loading history…" : "No recorded history for this range."}

)}
); }