Skip to main content

Module chart

Module chart 

Source
Expand description

Line · bar · scatter — the everyday XY chart, one themeable Elm [Facet]. Data goes in as the simplest possible model — a Vec of named series, each a Vec<(x, y)> — and everything else (axis bounds, gridlines, the legend, the hover tooltip) is derived. The chart kind is a single field in the model, so flipping line↔bar↔scatter is one Msg and is fully observable headlessly.

Series are colour-coded from the categorical palette in fixed slot order (a small validated set, consistent across light/dark themes) — never a per-string hash — so identity reads the same every render and the colours stay CVD-separable. The data→geometry math (ChartView::x_bounds / ChartView::y_bounds) is pure and unit-tested with no GPU.

Structs§

ChartState
Persistent, observable interaction state (FC-3): the current chart kind and which (series, point) the pointer last hovered. Serialized so it round-trips through the headless JSON seam.
ChartView
A line/bar/scatter chart over a set of named series.
Series
One named data series: a label (for legend + a11y) and its (x, y) points.

Enums§

ChartEffect
FC-8: the chart does no I/O — an uninhabited effect.
ChartKind
Which mark the chart draws. One field in the model — switching is one ChartMsg.
ChartMsg
FC-2 input surface. Externally-tagged serde so a robot posts JSON: {"set_kind":"bar"} · {"hover":[0,1]} · {"hover":null}.