Hi,
Is there any way to make the anchor/alignment/offset dynamic but fixed? Like make it a callback or something else?
I am setting up the position of labels in the chart but for some cases the position of labels is not perfect, like the 11% in the pic

You can use scriptable options, for example (jsfiddle):
options: {
plugins: {
datalabels: {
align: function(context) {
return context.dataset.data[context.dataIndex] < 15 ? 'end' : 'start';
},
color: function(context) {
return context.dataset.data[context.dataIndex] < 15 ? 'black' : 'white';
}
// ...
}
}
}
Thanks! It worked
I tried this way, maybe I missed a comma or other mistakes at that time.
Most helpful comment
You can use scriptable options, for example (jsfiddle):