DEV Community

Cover image for Create a Chart with multiple Dataset switching via state [React + react-chartjs-2 Tutorial]
Chris Godber
Chris Godber

Posted on

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.

Top comments (0)