1π
β
To gather labels from all datasets, you should include all datasets into your loop:
for(var j = 0; j < chart.data.datasets.length; j++){
for (var i = 0; i < chart.data.datasets[j].data.length; i++) {
text.push('<li class="list-inline-item"><small><i class="fas fa-circle pr-1" style="color:' +
chart.data.datasets[j].backgroundColor[i] + '"></i>');
if (chart.data.datasets[j].labels[i]) {
text.push('<span class="font-weight-bold">' + chart.data.datasets[j].labels[i] + '</span>');
}
text.push('</small></li>');
}
}
Source:stackexchange.com