0👍
✅
Have you read about the datalabels
plugin for chart.js
? You can find more info here.
After importing that library, you can update your chart config as follows:
options: {
plugins: {
datalabels: {
align: 'end',
anchor: 'end',
color: 'black',
formatter: function(value, context) {
return context.chart.data.labels[context.dataIndex] + ': ' + value;
}
}
}
}
The formatter
attribute is the crucial part here.
Source:stackexchange.com