Skip to main content
Recharts uses a declarative approach to map data to visual elements. Understanding how data flows through the chart and how layouts determine coordinate systems is essential for building effective visualizations.

Data structure

Recharts works with plain JavaScript arrays of objects. Each object represents a data point.

Basic data format

Each object can have any number of properties. Recharts accesses these properties using the dataKey prop.

Nested data

Data can include nested objects:

Array data

For scatter plots or bubble charts, data points can be coordinate pairs:

The dataKey prop

The dataKey prop is the primary mechanism for connecting data to visual elements. It specifies which property to extract from each data object.

String dataKey

Most common usage - a string property name:

Function dataKey

For complex data transformations, use a function:
Function dataKey receives the entire data point object and should return a value that can be plotted.

Nested dataKey with dot notation

Layout prop

The layout prop determines the orientation of the chart and how axes are mapped to data.

Horizontal layout (default)

In horizontal layout:
  • XAxis represents the category (discrete values)
  • YAxis represents the value (continuous values)
  • Bars/lines grow vertically

Vertical layout

In vertical layout:
  • XAxis represents the value (continuous values)
  • YAxis represents the category (discrete values)
  • Bars/lines grow horizontally

Polar layouts

Polar charts use different layout values:

Coordinate systems

Recharts transforms your data through coordinate systems to determine pixel positions.

Cartesian coordinate system

Cartesian charts use X and Y coordinates:
The transformation involves:
  1. Domain: The range of your data values (e.g., 0 to 1000)
  2. Range: The pixel range available (e.g., 0 to 400)
  3. Scale: The function that maps domain to range
In SVG, the Y-axis increases downward. Recharts automatically inverts it so higher values appear at the top.

Polar coordinate system

Polar charts use angles and radii:

Axis types

Recharts supports different axis types that determine how data is scaled.

Category axis

For discrete, non-numeric values:
Category axes distribute items evenly regardless of their actual values. Each category gets equal spacing.

Number axis

For continuous numeric values:
Number axes scale proportionally. A value of 25 appears halfway between 0 and 50.

Domain configuration

The domain prop controls the range of values displayed on an axis.

Auto domain (default)

Recharts automatically calculates domain from data:

Fixed domain

Explicitly set min and max:

Dynamic domain

Use special keywords:

Function domain

Calculate domain dynamically:
Always start from zero for better comparison:

Data transformations

Stacking data

Multiple bars or areas with the same stackId are stacked:
Stacking behavior:
  • First bar starts from baseline (0 or domain min)
  • Second bar starts where first bar ends
  • Third bar starts where second bar ends

Percentage stacking

Normalize stacks to 100%:

Synchronized charts

Share interactions across multiple charts:
Charts with the same syncId synchronize their tooltip positions and active states.

Data point coordinates

Access computed coordinates in custom components:
Coordinate props available:
  • cx, cy: Center coordinates (for dots, scatter points)
  • x, y: Top-left coordinates (for bars, rectangles)
  • width, height: Dimensions (for bars, rectangles)
  • payload: Original data object
  • value: The plotted value from dataKey