Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

React Chart.js 2

React components wrapper for Chart.js enabling data visualization with charts.

Charts and data visualisationNPM

GitHubWebsite

1. License

License from npm.

github.com/reactchartjs/react-chartjs-2

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What React Chart.js 2 does

react-chartjs-2 is a thin layer of React components over Chart.js. You choose and register the Chart.js parts your charts need, and typed components such as <code>Line</code> or <code>Doughnut</code> register their own controller.

React Chart.js 2 popularity

64 / 100
Gid Score, #763 overall
6.2M
downloads a week, npm
6,939
GitHub stars
41
agent projects use it
React Chart.js 2: downloads per weeknpm, react-chartjs-2 6,195,944
React Chart.js 2: GitHub starsreactchartjs/react-chartjs-2 6,939

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How React Chart.js 2 is used

  • React Chart.js 2 is a dependency in 41 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.8% of the 4,867 JavaScript/TypeScript ones), #8 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 158; those are left out of every share on this page.
  • The most used alternative in our scan is Recharts (576 projects).
  • Projects that use it most often also use Chart.js (97.6%), Lucide React (85.4%), React (100.0%).

By coding agent

24 projects, 1.0%
20 projects, 0.7%
18 projects, 0.5%

Often used with

In 97.6% of its projects
In 85.4% of its projects
In 100.0% of its projects
In 73.2% of its projects
In 65.9% of its projects
In 65.9% of its projects
In 90.2% of its projects
In 68.3% of its projects

React Chart.js 2 in practice

Strengths

You decide what goes in the bundle

The docs describe a "lazy way", <code>import 'chart.js/auto'</code>, and a tree-shakable way where you register only the parts you use. The maintainers recommend the second to keep the bundle smaller.

Typed components register their own controller

With a component like <code>Line</code>, you do not register <code>LineController</code> yourself. You register only the elements, scales and plugins.

Works with Chart.js v4 and v3

The site says both major Chart.js versions are supported and links a separate guide for v3.

The chart instance is one ref away

A <code>ref</code> on the component gives you the Chart.js chart. The docs' gradient example reads <code>chart.ctx</code> from <code>chartRef.current</code> to build a background gradient.

Watch out for

Registration errors are a known question

The FAQ lists entries on fixing "not a registered element" and "not a registered scale" errors. It also lists questions about charts that do not keep their width or height, and background fills that do not work.

Chart.js is a separate install

You add <code>chart.js</code> alongside <code>react-chartjs-2</code>. The README recommends a specific major version of Chart.js.

v4 removed the chart.js re-exports

Imports like <code>defaults</code> and the Chart.js <code>Chart</code> class now come from <code>chart.js</code>, not from this package. The old default export became the named <code>Chart</code> component.

Line component with tree-shaken registration

import { Line } from 'react-chartjs-2' ;
import { Chart as ChartJS , LineElement , PointElement , LinearScale , Title } from 'chart.js' ;
ChartJS . register ( LineElement , PointElement , LinearScale , Title ) ;
< Line data = { chartData } />

More about React Chart.js 2

Packages around it
  • chart.js: Charting engine (peer dependency)
  • framer-motion: Animation
  • react: UI library
  • lucide-react: Icons
  • react-router-dom: Routing
  • date-fns: Date utilities
More in Charts and data visualisation

Alternatives

React Chart.js 2 This page

MITGid 646.2M/wk

Recharts

Composable React component library for building responsive charts.

MITGid 8571.4M/wk

D3.js

JavaScript library for creating data-driven documents with powerful data visualization capabilities.

ISCGid 8136M/wk

React ApexCharts

React wrapper for ApexCharts with server-side rendering support.

SEE LICENSE IN LICENSE.mdGid 481.5M/wk

Compare React Chart.js 2 with another tool

Get started

Install it.

npm install react-chartjs-2

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## react-chartjs-2
- Install both packages: `react-chartjs-2` and `chart.js`. The README recommends `chart.js@^4.0.0`.
- Before rendering, register the Chart.js elements, scales and plugins a chart needs with `ChartJS.register(...)`. Typed components like `Line` already register their controller.
- Prefer tree-shakable registration over `import 'chart.js/auto'`. The docs call the auto import the "lazy way".
- Import `Chart as ChartJS`, `defaults` and the elements from `chart.js`. This package no longer re-exports them.
- For click data, attach a `ref` and call `getDatasetAtEvent`, `getElementAtEvent` or `getElementsAtEvent` with `chartRef.current` and the event inside `onClick`.
- Do not pass a function to `data`. For gradients, read `chart.ctx` from a ref in `useEffect` and set the data with state.