You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, at the configuration > legend section, if you scroll down to custom onClick actions, it says the default behavior is this
function(e, legendItem, legend) {
const index = legendItem.datasetIndex;
const ci = legend.chart;
if (ci.isDatasetVisible(index)) {
ci.hide(index);
legendItem.hidden = true;
} else {
ci.show(index);
legendItem.hidden = false;
}
}
However this is not correct. When I copied and pasted that code into my options.plugins.legend.onClick function, I got several errors summarized perfectly in this stackoverflow post.
The post also explains the fix and the purpose of this issue, which is to update the chartjs Docs to say, the current default behavior is actually
Do you have a reproducible sample of your error, since this implementation in the docs is not outdated. This is the exact implementation the legend plugin currently uses.
Documentation Is:
Please Explain in Detail...
Currently, at the configuration > legend section, if you scroll down to custom onClick actions, it says the default behavior is this
However this is not correct. When I copied and pasted that code into my options.plugins.legend.onClick function, I got several errors summarized perfectly in this stackoverflow post.
The post also explains the fix and the purpose of this issue, which is to update the chartjs Docs to say, the current default behavior is actually
Your Proposal for Changes
Change the documentation to be correct as stated above.
Example
https://www.chartjs.org/docs/latest/configuration/legend.html#custom-on-click-actions
The text was updated successfully, but these errors were encountered: