Chartjs-Add new line in es6 inside a doughnut chart

2👍

Well, I see you haven’t found your desired solution yet. SO, here’s the solution…

add the following code after const centerY = (chart.chartArea.top + chart.chartArea.bottom)/2
in your plugin

let helpers = Chart.helpers;
let fontSize = helpers.getValueOrDefault(centerConfig.minFontSize, 1);
let text = centerConfig.text.split('\ ');
ctx.fillText(text[0], centerX, centerY - fontSize / 2);
ctx.fillText(text[1], centerX, centerY + fontSize / 2);

1👍

See Escape notation:

let stringTemplateA = `-a
a-`;

let stringTemplateB = `-b\r\nb-`;

console.log(stringTemplateA);
console.log(stringTemplateB);

Leave a comment