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:LineChart, BarChart, AreaChart, ComposedChart, PieChart, RadarChart, ScatterChart.
Axes
Axes define how data maps to visual coordinates:dataKey prop tells the axis which field from your data to use.
Data series
Data series components visualize your data: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
Next steps
- Learn about tooltips and legends for better interactivity
- Configure axes and grids for precise control
- Add animations to make your charts engaging
- Explore responsive containers for adaptive layouts