Closed cankut closed 8 years ago
Following :-)
For me it worked to use this:
//Hide
chart.getDatasetMeta(1).hidden=true;
chart.update();
//Show
chart.getDatasetMeta(1).hidden=null;
chart.update();
Where 1 is the index of RGB in the dataset.
@mennodekker has the correct answer
@mennodekker is right. Just one point: instead of null, better to use false.
The reason is that if the dataset is hidden in the first place, programmatically setting hidden to null won't actually show the dataset.
//Hide
chart.getDatasetMeta(1).hidden=true;
chart.update();
//Show
chart.getDatasetMeta(1).hidden=false;
chart.update();
I'm actually facing a similar issue. I"ve make a custom legend component and I'm able to show/hide using the above codes. However, this only works for bar chart. It raise the following exception when using it with donut chart:
TypeError: Cannot read property '_meta' of undefined at Chart.getDatasetMeta (core.controller.js:656)
Have anyone faced a similar issue please?
Is there anyway to hide or show specific lines, and not the whole chart? @mennodekker 's way of doing this toggles the whole chart.
I'm actually facing a similar issue. I"ve make a custom legend component and I'm able to show/hide using the above codes. However, this only works for bar chart. It raise the following exception when using it with donut chart:
TypeError: Cannot read property '_meta' of undefined at Chart.getDatasetMeta (core.controller.js:656)
Have anyone faced a similar issue please?
Yes I faced similar.
Hi,
When i click on the legend items they are toggled in the chart. strikethrough items are not rendered.
How can i do the same thing by using chart instance, instead of clicking on legend items?
some code like;