Chartjs-Chart js Datalabels styling

0👍

You need to make a function to change the colors depending their label:

plugins: {
    datalabels: {
        anchor: 'end',
        align: 'end',
        color: function(context) {
            var index = context.dataIndex;
            var value = context.dataset.data[index];
            var valueRed = context.dataset.label;

            if(valueRed === 'Monthly') {
                return value = 'red';
            } else {
                return value = '#000';
            }
        }
    }
}

Here is a working example: Plunker example

More info about formatting in the plugin’s page: Scriptable Options

Leave a comment