Skip to main content
Recharts is a composable charting library built with React and D3. This guide walks you through creating your first chart.

Installation

Install Recharts via npm or yarn:

Your first chart

Let’s create a simple line chart that visualizes monthly revenue data.
1

Prepare your data

Recharts works with plain JavaScript arrays of objects:
2

Import components

Import the chart container and components you need:
3

Build your chart

Compose your chart using declarative components:

Understanding the structure

Every Recharts chart follows a consistent pattern:

Chart container

The outer container defines the chart type:
Available chart types: LineChart, BarChart, AreaChart, ComposedChart, PieChart, RadarChart, ScatterChart.

Axes

Axes define how data maps to visual coordinates:
The dataKey prop tells the axis which field from your data to use.

Data series

Data series components visualize your data:
Each series needs a dataKey that matches a field in your data.

Interactive components

Add interactivity with Tooltip and Legend:

Multiple data series

Add multiple series to compare data:

Bar chart example

Switch to a bar chart by changing the container and series component:

Common pitfalls

Data keys must match your data structureIf your data has a field called sales, use dataKey="sales", not dataKey="revenue".
Always wrap charts in ResponsiveContainerThis ensures your chart adapts to different screen sizes. Set width to "100%" to fill the parent container.

Next steps