Documentation Is:
Please Explain in Detail...
Concerning https://www.chartjs.org/docs/latest/configuration/legend.html
The example for overriding legend onClick is outdated. The code throws error Uncaught TypeError: Cannot read properties of null (reading '_resolveAnimations'
it is currently:
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;
}
}
Your Proposal for Changes
It should be
legend.chart.toggleDataVisibility(legendItem.index);
legend.chart.update();
Example
No response