I'm working with this plugin: How to add text in centre of the doughnut chart using Chart.js?
I adapted it to my needs, but I'm stuck at trying to change the color in a similar way to how I change the text.
Chart.pluginService.register({
beforeDraw: function(chart) {
var width = chart.chart.width,
height = chart.chart.height,
ctx = chart.chart.ctx;
ctx.restore();
var fontSize = (height / 134).toFixed(2);
ctx.font = fontSize + "em fuenteTitulos";
ctx.textBaseline = "middle";
labelFontColor : "#DC1B3A"
var legendHeight = chart.legend.height;
var text = chart.options.centertext,
textX = Math.round((width - ctx.measureText(text).width) / 2),
textY = height / 2;
ctx.fillText(text, textX, textY);
ctx.save();
}
});
It is important to mention that I have multiple graphs in the same view and script. The centertext
option is given for each different graph and I would like to do the same with the color of each.