How can I make a html legend from Chart.js
to hide/show the dataset
of the chart, like the legend generated by the Chart.js
itself
Legend on bottom -> Chart.js legend
Legend on right-> HTML
How can I click in "SETOR AGILIZA" and get the dataset
relative to it hide/show
I found this code in the chat.js/core.legend.js core.legend
onClick: function(e, legendItem) {
var index = legendItem.datasetIndex;
var ci = this.chart;
var meta = ci.getDatasetMeta(index);
// See controller.isDatasetVisible comment
meta.hidden = meta.hidden === null? !ci.data.datasets[index].hidden : null;
// We hid a dataset ... rerender the chart
ci.update();
},
But I have no clue how to get it to work on a onClick
event in the html legend
the labels names are get from a database, so they can change.
UPDATE 1
Found this Github, trying to make it work