Filter A Legend Item With Chartjs.org V2.7
I am building a series of doughnut charts and I would like to remove the second item in the legend, so when I generate the legend with the generateLegend() method I just want to ge
Solution 1:
The filter function works exactly like the Javascript's native Array.prototype.filter
. So just return true if you want to show the legend at a particular index.
EDIT: The filter function would come inside the labels
field.
legend: {
display: true,
labels: {
filter: function(legendItem, data) {
return legendItem.index != 1
}
}
}
Post a Comment for "Filter A Legend Item With Chartjs.org V2.7"