Create a Chart with multiple Dataset switching via state [React + react-chartjs-2 Tutorial]

drnoir

Chris Godber

Posted on October 17, 2020

Create a Chart with multiple Dataset switching via state [React + react-chartjs-2 Tutorial]


SOURCECODE- https://github.com/drnoir/switchingcharts-demo

This tutorial goes over a basic overview of a method to create a chart in a class component in react using react-chartjs-2 and how to update the chart with different data using SetState within that chart based on onClick events within the component - in this example 3 months, 6 months and a year.

In a real life example you would probably get your data from props, or state but this should provide a good starting point for understanding how to do this.

💖 💪 🙅 🚩
drnoir
Chris Godber

Posted on October 17, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related