react-chartjs-2
React components for Chart.js, the most popular charting library
A React library that lets you add bar charts, line charts, doughnuts, scatter plots, and more to your app by importing a chart component and passing your data as a prop, no custom drawing code needed.
react-chartjs-2 is a library that makes it straightforward to add charts to React web applications. It wraps Chart.js, a widely used JavaScript charting library, so that React developers can use charts the same way they use any other React component: by importing the chart type they need and passing data to it as a property.
The library supports Chart.js versions 3 and 4 and is installed alongside Chart.js as a peer dependency. A two-line example in the README shows importing a Doughnut chart component and placing it in a page by passing in a data object. The same pattern applies to the other chart types that Chart.js supports, such as bar charts, line charts, and scatter plots, though the README itself is brief and points to the documentation site for the full list of components and examples.
Installation uses a standard package manager command (npm, yarn, or pnpm). The library is MIT licensed.
The documentation site covers working with datasets, handling user interaction events, a FAQ, a component reference, and a set of live examples. There is also a Stack Overflow tag for community questions.
This repository is the glue layer between two existing tools rather than a standalone charting system. If you are already comfortable with React and want interactive charts without leaving the React component model, this library handles the integration details. The README is concise and the project itself is mature, reflecting that most questions are better answered by the Chart.js documentation or the project's own documentation site.
Where it fits
- Add a bar chart or line chart to a React app by importing one component and passing a data object as a prop
- Display a doughnut or pie chart in a React dashboard with just two lines of import and JSX
- Handle user click events on chart segments to trigger actions or show details inside a React component