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.
- Chartjs-How do I fix the size of bars from horizontal chartjs?
- Chartjs-Is there a way to pass rendered variables from pug templates to client side JS files?
Source:stackexchange.com