-
I am attempting to create a nested pie/doughnut chart in ChartJS 3 and am having issues with correctly displaying the data when one of the outer segments are hidden using the legend. The second inner ring of data is just the outer ring split into more specific segments:
When the user hides GROUP1 the correct outer segment is hidden but only the first inner segment is hidden instead of the first and second (300 + 241 = 541). So I'm wondering how I can correctly group the two datasets so that all nested data is hidden. I have attached a sample below demonstrating the issue: https://jsfiddle.net/yp4o16nd/
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You would need to write a custom https://www.chartjs.org/docs/master/configuration/legend.html#custom-on-click-actions |
Beta Was this translation helpful? Give feedback.
-
Hi LukePrior, Based on LeeLenalee I tried to create something and mostlikely you want to convert the legend into a style similar to bar chart where the dataset would show/hide if clicked on. In case you need to understand what has been done watch this here: https://youtu.be/_M8ijxCE7mY The code below shows you the config block. Just add it in your code and it will work nicely. Hope this helps.
|
Beta Was this translation helpful? Give feedback.
-
This was what I ultimately ended up with: https://jsfiddle.net/hktjxncw/4/ |
Beta Was this translation helpful? Give feedback.
Hi LukePrior,
Based on LeeLenalee I tried to create something and mostlikely you want to convert the legend into a style similar to bar chart where the dataset would show/hide if clicked on.
In case you need to understand what has been done watch this here: https://youtu.be/_M8ijxCE7mY
The code below shows you the config block. Just add it in your code and it will work nicely. Hope this helps.