Reference Lines
Mark targets, thresholds, ranges, and notable points on a Cartesian chart.
Usage
Reference marks put context on the plot: a target or service level as a line, an incident or a weekend as a shaded band, and an annotated point such as a peak or a release. Add them as children of the chart root, in any order, next to the series they describe.
import { LineChart } from "honestui/charts";
<LineChart data={data} config={chartConfig} xDataKey="day">
<LineChart.ReferenceArea x1="Jun 5" x2="Jun 6" label="Incident" />
<LineChart.ReferenceLine y={200} label="SLO 200ms" />
<LineChart.ReferenceDot x="Jun 5" y={248} label="Peak" labelPosition="right" color="p95" />
<LineChart.Line dataKey="p95" />
</LineChart>;Positions use the screen axes: x is a place on the horizontal axis and y on the vertical axis, in either bar layout. On a category axis pass the category exactly as it appears in the data; on a value axis pass a number. A horizontal bar chart's target is therefore <BarChart.ReferenceLine x={target} />, a vertical line across value space.
By default a mark outside the plotted values widens the value axis so it stays visible. Set extendDomain={false} to keep the axis fitted to the data and let the mark fall off the plot. Labels are not counted: a dot at the highest value has no room above it, so give its label labelPosition="right" or another side with space.
Examples
Line chart
A shaded incident window, a dashed objective, and an annotated peak drawn in the series color.
Bar chart
A goal line across grouped bars, with the label at the start of the line.
Area chart
A band marking the target range behind a stacked area.
Scatter chart
Average lines on both value axes split the field into four groups.
Combo chart
A sale period and a revenue target. Marks are measured against the left value axis.
Waterfall chart
A plan line across the bridge shows where the result lands against it.
Look
Lines are one pixel wide and dashed like the tooltip cursor, in the muted foreground, so they read as guides rather than data. Labels are small pills on the chart's background with a border in the chart's border color, sitting above a horizontal line or just inside the top of a vertical one. Areas are a faint wash of the foreground, or a tint of their color. A color may be a key from the chart config, which takes that series' first color in both themes, or any CSS color.
Accessibility
Reference marks are drawn on the canvas and are not announced. When a threshold matters to the reader, state it in text near the chart or in the chart's ariaLabel, for example "p95 latency, objective 200 ms, exceeded on June 5 and 6".
Supported Charts
AreaChart, BarChart, LineChart, ScatterChart, ComboChart, WaterfallChart, and CandlestickChart all expose ReferenceLine, ReferenceArea, and ReferenceDot with the same props.