The forecast prop on LineChart provides built-in statistical overlays. The line splits into three visual segments:training (dashed),observed (solid), andforecast (dotted with confidence envelope).
Auto mode computes regression from training data and extrapolates. Pre-computed mode reads segment flags and bounds from your data — use this when bounds come from an ML model. The envelope follows per-point upper/lower bounds (non-rectilinear), and anomalous points are flagged via an isAnomaly field.
In auto mode a dashed boundary line marks trainEnd.boundaryColor, boundaryDasharray andboundaryLabel restyle and relabel it;boundaryLabel: false keeps the line without a label, andshowBoundary: false removes it. The label takes the line's color unless boundaryLabelColor sets its own, and sits on a halo in the plot background unless boundaryLabelBackgroundsets another backdrop ("box", "none", or a config such as { type: "box", fill }), so a faint line can keep a readable label. The browser andrenderChart draw it the same way.
Reading the overlays in a tooltip
Every row the chart draws carries its segment inFORECAST_SEGMENT_FIELD ("training","training-base", "observed" or"forecast"), and each row the anomaly overlay flags carries ANOMALY_FIELD set to true: the same rows it draws a dot for. With function accessors, the rows also hold the resolved values in RESOLVED_X_FIELD andRESOLVED_Y_FIELD, which is the only place a computed forecast row has its x and y. All four are exported from semiotic/xyand semiotic/line.
JSX
import { LineChart, ANOMALY_FIELD, FORECAST_SEGMENT_FIELD } from "semiotic/xy" <LineChart data={data} xAccessor="time" yAccessor="value" forecast={{ trainEnd: 70 }} anomaly={{ threshold: 2 }} tooltip={{ mode: "multi", content: ({ allSeries }) => { const row = allSeries[0].datum return row[ANOMALY_FIELD] ? "Anomaly" : row[FORECAST_SEGMENT_FIELD] }, }} />
Train/Forecast split at x=60 · 80 points
Forecast
Boundary
Anomaly
Line
Generated Code
JSX
import { LineChart } from "semiotic" // Auto: Linear Trend + Anomalies const data = [...] // Auto: Linear Trend + Anomalies <LineChart data={data} xAccessor="time" yAccessor="value" showGrid forecast={{ trainEnd: 60, }} anomaly={{}} />