Control multiple charts with one legend react-chartjs2

432 views Asked by At

I'm using react-chartjs2 and chart.js to display datasets for a web application I'm building. The user is going to have the option of selecting how many charts to view for different items. Each item will have its own chart, but fields/labels for the datasets will be the same for each item. This being the case I want for the user to be able to hide lines for different charts using one single legend. I don't want to display a legend for each chart that gets generated, just have one at the top.

I have a general idea on how to do this. The issue is that each chart is its own React Component. I'm trying to access all the other charts in one of the components and iterate through each instance of charts and modify the data that way. Any idea on how this can be done?

0

There are 0 answers