Chartjs-Change the Center color of doughnut chart in Chart.Js

0👍

The background is transparent. I think you can’t really color the midle circle..
The main option is to put a background color on canvas or chart but all the white spaces will be colored.

0👍

its transparent , takes background colour

0👍

Use chart.js 3.8

const colorcenter = {
  id: 'colorcenter',
  beforeDraw(chart, args, options) {
    const {ctx, chartArea: {top, right, bottom, left, width, height}} = chart;
    const radius = chart._metasets[0].controller.innerRadius;
    const x = chart.getDatasetMeta(0).data[0].x;
    const y = chart.getDatasetMeta(0).data[0].y
    ctx.arc(x, y, radius, 0, 2 * Math.PI);
    ctx.fillStyle = options.backgroundColor;
    ctx.fill();
  }
}

Leave a comment