Skip to main content
Get up and running with Recharts by building your first chart in just a few steps.

Prerequisites

Before you begin, make sure you have:
  • Node.js 18 or higher installed
  • A React application set up (React 16.8+)
  • Basic understanding of React components

Create your first chart

1

Install Recharts

Install Recharts and its peer dependency react-is:
The react-is version should match your installed React version.
2

Prepare your data

Create a data array with objects. Each object represents a data point:
3

Import chart components

Import the chart components you need:
4

Render your chart

Compose your chart using declarative components:

Understanding the components

Your first chart uses several key Recharts components:
  • LineChart - The container component that sets up the coordinate system
  • Line - Renders the line series using the dataKey prop to specify which data field to visualize
  • XAxis and YAxis - Display the horizontal and vertical axes
  • CartesianGrid - Adds the background grid lines
  • Tooltip - Shows data details on hover
  • Legend - Displays the legend for your data series

Customization examples

Multiple data series

The example above already shows two lines (pv and uv). Each Line component creates a separate series:

Change line style

Customize the line appearance with different interpolation types:
Available types: basis, basisClosed, basisOpen, linear, linearClosed, natural, monotoneX, monotoneY, monotone, step, stepBefore, stepAfter.

Add dots to data points

Show dots at each data point:

Connect null values

Handle missing data by connecting around null values:

Understanding dataKey

The dataKey prop tells components which field in your data objects to visualize. It can be:
  • A string: Direct property access (dataKey="uv")
  • A nested path: Dot notation for nested objects (dataKey="user.name")
  • A function: Custom data accessor (dataKey={(data) => data.value * 2})

Make it responsive

Wrap your chart in ResponsiveContainer to make it adapt to its parent size:
Always use ResponsiveContainer in production to ensure your charts work on all screen sizes.

Next steps

Explore examples

See more chart examples and variations

Core concepts

Learn about chart types and architecture

API reference

Explore all props and options

Customization

Learn how to style and customize charts