score:0

Accepted answer

by reading the documentation better a unique id must be configured for each registered plugin.

plugins must define a unique id in order to be configurable.

so i just added the id in my code

chart.register({
    id: 'no_data_label',
    afterdraw: (chart, args, options) => {
        const data = chart.data.datasets[0].data;
        if (data.length === 0) {
            // no data is present
            console.log(chart)
            const current = chart.ctx;
            const width = chart.width;
            const height = chart.height
            chart.clear();

            current.save();
            current.textalign = 'center';
            current.textbaseline = 'middle';
            current.font = "16px normal 'helvetica nueue'";
            current.filltext('nessun dato disponibile', width / 2, height / 2);
            current.fontcolor = "#828282";
            current.restore();
        }
    }
});

Related Query

More Query from same tag