Skip to main content
Recharts provides a set of React hooks that allow you to access chart data, scales, and state from within custom components. All hooks must be used within a chart context (inside a LineChart, BarChart, etc.). Using them outside a chart will return undefined.

Hook categories

Tooltip hooks

Access tooltip state and active data points.
  • useIsTooltipActive - Check if tooltip is currently visible
  • useActiveTooltipLabel - Get the active label
  • useActiveTooltipDataPoints - Get active data points
  • useActiveTooltipCoordinate - Get tooltip coordinates
View tooltip hooks documentation

Axis hooks

Access axis properties, domains, and ticks.
  • useXAxis / useYAxis - Get axis configuration
  • useXAxisDomain / useYAxisDomain - Get axis domain
  • useXAxisTicks / useYAxisTicks - Get axis ticks
View axis hooks documentation

Scale hooks

Convert between data values and pixel coordinates.
  • useXAxisScale / useYAxisScale - Convert data to pixels
  • useXAxisInverseScale / useYAxisInverseScale - Convert pixels to data
  • useCartesianScale - Convert data points to pixel coordinates
View scale hooks documentation

Chart layout hooks

Access chart dimensions and layout information.

useOffset

Returns the offset of the chart in pixels. The offset defines the blank space between the chart and the plot area, occupied by axes, legends, and brushes. Returns: ChartOffset | undefined

usePlotArea

Returns the plot area where chart data is rendered (bars, lines, scatter points, etc.). Returns: PlotArea | undefined

Usage example