DEV Community

Michael Warren
Michael Warren

Posted on

Getting Started with Data Visualization in React using Chart.js

I recently developed a CRUD application with React, and one of the unique features I wanted to add was a way to visualize the data used in the application as a line chart and bar chart. In my research, I found that there are several libraries specifically designed for React to accomplish this instead of directly using D3.js . Some of the libraries I considered include:

After some experimentation, I found that react-chartjs-2 was the easiest for me to grasp. react-chartjs-2 is a set of React components for Chart.js.

I found these two videos incredibly helpful for getting started with Chart.js:

In my case, I needed to use fetch to access the data from a JSON file, and pass it into the data property. I used this video as a guide:

And I used these two component examples to model my display for the data:

Top comments (0)