react-chartjs-2 provides React components for Chart.js chart types. Install it alongside chart.js and register only the chart elements you need.
Overview
react-chartjs-2 bridges Chart.js and React applications by exporting chart components that accept Chart.js configuration objects. It supports current Chart.js major releases, with migration notes between versions available in project documentation.
Typical usage installs chart.js as a peer dependency, registers required elements such as scales, arcs, or legends on the Chart.js registry, then renders components like Doughnut or Line inside React trees. Tree-shaking guidance explains importing granular modules from chart.js to limit bundle size.
Documentation covers dataset handling, event callbacks, FAQ topics, and live examples. Consumers are directed to Stack Overflow for usage questions and GitHub issues for defects. The package is distributed on npm under an MIT license.
Key features
- React chart components
- Chart.js v3 and v4 compatibility
- Tree-shakeable Chart.js imports
- Per-chart element registration
- Documented dataset and events
- Published npm package
- Live example gallery
- Migration guides between versions
Use cases
- Embedding charts in React UIs
- Dashboard data visualization
- Interactive chart event handling
- Migrating Chart.js apps to React