[Chartjs]-Filter a legend Item with Chartjs.org V2.7

8👍

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 
           }
      }
 }

Leave a comment