Chartjs-BeforeDraw in Chart JS 3.5.x

0๐Ÿ‘

2 main things, plugins need an ID. Also you might want to log every line or put breakpoints to see what is going on because afaik the chart does not contain a circulair reference to itself anymore.

So in your first if statement it should just be: if(chart.config.type === 'doughnut').

So basicly your first few lines have to be changed to this:

Chart.register({
 id: 'customText',
 beforeDraw: function(chart,args,options) {
     
     if(chart.config.type=='doughnut')

This will probably fix your problem, if not try to log variables you are using and check if you still call them in the correct way.

Leave a comment