0👍
The legend has a filter parameter which you can use to hide same labels: https://www.chartjs.org/docs/latest/configuration/legend.html#legend-label-configuration
EDIT:
Sample to filter out all duplicates: https://jsfiddle.net/Leelenaleee/vto6z3g4/15/
options: {
legend: {
labels: {
filter: (legendItem,chartData) => {
return !(chartData.labels.indexOf(legendItem.text) < legendItem.index);
}
}
}
}
- Chartjs-How to bind data from Controler to chartjs line chart to create it as dynamic?
- Chartjs-Chart.js scatter chart stops working after extending to multiple datasets
Source:stackexchange.com