Docs/Cartesian Components/ReferenceLine

ReferenceLine

ReferenceLine draws a horizontal, vertical, or diagonal line at a data coordinate. Use it to annotate the chart with thresholds, targets, or other important values.

import { ReferenceLine, LineChart } from "solid-recharts";

<LineChart data={data}>
  <ReferenceLine y={3000} stroke="#ff7300" label="Target" />
  <ReferenceLine x="Jan" stroke="#ccc" />
</LineChart>;
ReferenceLine
reference-lines.tsxOpen ↗
Loading source...

Props

PropTypeDefaultDescription
xnumber | string—Vertical line at this x-data coordinate
ynumber | string—Horizontal line at this y-data coordinate
segment[[x?, y?], [x?, y?]]—Diagonal line between two data coordinates
strokestring"#ccc"Line color
strokeWidthnumber1Line thickness in pixels
strokeDasharraystring—Dash pattern (e.g., "5 5")
labelstring | boolean | ReactNodefalseText label rendered along the line
ifOverflow"discard" | "hidden" | "extendDomain""discard"Behavior when the line exits the chart area
zIndexnumber—Stacking order (higher renders on top)

Notes

  • Only y (horizontal) or x (vertical) can be set alone; segment requires both endpoints.
  • Set strokeDasharray="5 5" for dashed lines.
  • label can be a string, boolean, or component — string labels render centered on the line.
  • ifOverflow="hidden" clips the line at the chart boundary; "extendDomain" expands axes if needed.

See also