useXAxisScale
Returns a function to convert data values to pixel coordinates for an XAxis. This is useful for positioning annotations, custom shapes, or other elements at specific data points on the chart. This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns Available since Recharts 3.8undefined if used outside a chart context, or if the axes don't exist.
Return value
ScaleFunction | undefined
A scale function that maps data values to pixel coordinates, or undefined.
Props
xAxisIdnumber | stringoptional
The
xAxisIdof the XAxis. Defaults to0if not provided.DEFAULT:
"defaultAxisId"