Skip to main content

Models

Analytics and Interaction

Trend lines (linear, log, exp, pow, polynomial, loess), rolling windows (mean, median, sum, min, max, exponential), additive Holt-Winters forecasts with a prediction band, and per-datum error bars — analytics={[{ kind: "trend", model: { poly: 3 } }]} and friends.

Examples

9 live examples

Trend Per Series

**One trend per series on a three-series `LineChart`.** Each `of` names its measure; the legend reads "Trend · Atlas (r² …)" so three dashed lines stay attributable. Toggling a series off hides its trend too.

Moving Average Replace

**`window` k=7 with `replace: true`.** The noisy daily series is swapped for its 7-point moving average, which takes the measure's token and the name "Sign-ups · 7-point moving average" — a transform OF the measure, not a model beside it, so it is solid and in the series colour.

Exponential Average Beside

**`window` with `reduce: "ewm"` beside the measure.** A 14-point exponentially weighted mean in the muted ink over the raw daily series; the tooltip adds it as a muted row under the measured value.

Six Month Forecast

**`forecast` — six months ahead, seasonal, with a 95 % prediction band.** Additive Holt-Winters with a 12-month season; the x axis extends to show the horizon, the path is dashed from the last actual month, and the band widens with the horizon. It never paints in the series colour.

Candlestick Moving Averages

**SMA 20 and EMA 50 on a `CandlestickChart`.** Moving averages of the closes: a simple 20-session mean and a 50-session exponential one, both in the muted ink beside the candles, labelled in the description.

Error Bars On Bars

**Error bars from two fields on a `BarChart`.** `low`/`high` name each estimate's bounds; the whiskers sit on the bar's own column and wait for the bars to finish growing. The tooltip reads the range.

Error Band By Percent

**An error band by percent on a `LineChart`.** `{ low: { percent: 8 }, band: true }` — ±8 % of each month's value, drawn as a band behind the line instead of whiskers. The tooltip shows the month's range as a muted row.

Trend With Confidence Band

**A linear trend with a 95 % confidence band** (`ci: 0.95`) and `extent: "domain"` — the fit across the whole x domain, the band widening away from the data's centre.