Recharts
Composable React component library for building responsive charts.
3. Used by agents' projects
Dependency in 576 public GitHub projects set up for AI coding agents that we scanned (9.2%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Recharts does
Recharts treats each part of a chart (axis, tooltip, grid, line) as its own React component, and draws the assembled chart as SVG.
Recharts popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Recharts is used
- Recharts is a dependency in 576 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (11.8% of the 4,867 JavaScript/TypeScript ones), #1 of 95 in charts and data visualisation.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,129; those are left out of every share on this page.
- The most used alternative in our scan is Chart.js (88 projects).
- Projects that use it most often also use Lucide React (92.7%), clsx (86.3%), Tailwind Merge (85.2%).
- It is more common in projects set up for Roo Code (19.8%) than for OpenCode (6.4%).
By coding agent
Often used with
Recharts in practice
Strengths
The README says a <code>LineChart</code> is composed of an x axis, a tooltip, a grid and line items. Each one is an independent React component. The maintainers call this separation one of the library's principles.
One developer picked Recharts for client PDF reports because of its SVG output and component design. It connected to React-pdf through the <code>react-pdf-charts</code> wrapper.
For a chart with positive and negative values, the same developer set <code>stackId</code> on each <code>Bar</code> and <code>stackOffset='sign'</code> on the <code>BarChart</code>. He writes that Recharts then places each bar on the correct side of the Y axis and stacks them.
The README gives three install routes: <code>npm install recharts react-is</code>, <code>deno add recharts react-is</code>, or UMD scripts from unpkg that expose <code>window.Recharts</code>.
Watch out for
Recharts has no title component. The author notes that many users find this frustrating, and suggests Flex or similar layout to center a title over the graph.
The author increased the chart's margins so everything fit inside the container. He says Recharts "seems to" have trouble with margin calculations once labels are involved.
In the author's view, building graphs in Recharts is easy but making them beautiful is harder. His post walks step by step through building one real graph component.
A line chart with two series
<LineChart width={400} height={400} data={data}>
<XAxis dataKey="name" />
<Tooltip />
<CartesianGrid stroke="#f5f5f5" />
<Line type="monotone" dataKey="uv" stroke="#ff7300" />
<Line type="monotone" dataKey="pv" stroke="#387908" />
</LineChart>More about Recharts
Funding
- Open Collective: https://opencollective.com/recharts
Head to head
- Recharts vs Chart.js used together in 25 projects
Packages around it
- lucide-react: Icon components
- clsx: Conditional class names
- tailwind-merge: Tailwind class merging
- class-variance-authority: Variant class names
- @radix-ui: UI primitives
- zod: Schema validation
More in Charts and data visualisation
Alternatives
Recharts This page
Simple HTML5 canvas-based charting library for creating interactive data visualizations.
JavaScript library for creating data-driven documents with powerful data visualization capabilities.
Powerful interactive charting library for data visualization in browsers.
Interactive JavaScript charting library for creating modern data visualizations.
React wrapper for ApexCharts with server-side rendering support.
Get started
Install it.
npm install rechartsRules for your agent
## Recharts
- Install with `npm install recharts react-is` (or `deno add recharts react-is`), and keep `react-is` at the same version as the project's `react`.
- Build charts by nesting components such as `XAxis`, `YAxis`, `Tooltip`, `CartesianGrid`, `Legend` and `Line`/`Bar` inside a chart component like `LineChart` or `BarChart`.
- Set `dataKey` on axes and series to a field name present in the objects of the `data` array.
- For a chart that sizes to its container, follow the site example: pass `responsive` and a `style` with `width: '100%'` and an `aspectRatio`.
- For bars with positive and negative values, give each `Bar` the same `stackId` and set `stackOffset='sign'` on the chart.
- There is no title component: render titles as ordinary elements outside the chart. If axis labels run outside the container, increase the chart's `margin` prop.
- For a script-tag setup, load react, react-dom and react-is UMD builds before `Recharts.js`, then use `window.Recharts`.