Usage
Props
number | string
If defined, renders a vertical line on this position.This value is using your chart’s domain, so you will provide a data value instead of a pixel value.
ReferenceLine will internally calculate the correct pixel position.
number | string
If defined, renders a horizontal line on this position.This value is using your chart’s domain, so you will provide a data value instead of a pixel value.
ReferenceLine will internally calculate the correct pixel position.
array
Tuple of coordinates. If defined, renders a diagonal line segment.
'start' | 'middle' | 'end'
default:"middle"
The position of the reference line when the axis has bandwidth
(e.g., a band scale). This determines where within the band
the line is drawn.
string
default:"#ccc"
The stroke color. If “none”, no line will be drawn.
number | string
default:"1"
The width of the stroke.
string | number
The pattern of dashes and gaps used to paint the line.
string
default:"none"
The fill color. Reference lines are typically not filled.
number
default:"1"
The opacity of the fill.
boolean | string | number | object | ReactElement | function
default:"false"
Renders a single label.
false: no labels are renderedstring|number: the content of the labelobject: the props of LabelList componentReactElement: a custom label elementfunction: a render function of custom label
ReactElement | function
If set a ReactElement or function, the shape of the line can be customized.
'discard' | 'hidden' | 'visible' | 'extendDomain'
default:"discard"
Defines how to draw the reference line if it falls outside the chart area.
discard: don’t render if outsidehidden: render but clip to chart areavisible: render even if outsideextendDomain: extend the axis domain to include the reference line
string | number
default:"0"
The id of x-axis which is corresponding to the data.
Required when there are multiple XAxes.
string | number
default:"0"
The id of y-axis which is corresponding to the data.
Required when there are multiple YAxes.
number
default:"400"
Z-Index of this component and its children. The higher the value,
the more on top it will be rendered.
Components with higher zIndex will appear in front of components with lower zIndex.
If undefined or 0, the content is rendered in the default layer without portals.@since 3.4
string | number
CSS class name for styling.
Notes
This component, unlike<line>, is aware of the cartesian coordinate system,
so you specify the dimensions by using data coordinates instead of pixels.
ReferenceLine will calculate the pixels based on the provided data coordinates.
If you prefer to render using pixels rather than data coordinates,
consider using the <line> SVG element instead.
Source
https://github.com/recharts/recharts/blob/main/src/cartesian/ReferenceLine.tsx