score:3

Accepted answer

Thanks to @DTul, I figured it out. The title configuration is here: https://www.chartjs.org/docs/latest/configuration/title.html.

I've added the following section:

title: {
   display: true,
   text: 'Custom Chart Title',
   position: 'bottom'
}

to the options.

The whole example looks now like that:

var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        rotation: 1 * Math.PI,
        circumference: 1 * Math.PI,
        title: {
           display: true,
           text: 'Custom Chart Title',
           position: 'bottom'
        }
     }
});

The corresponding fiddle is here: https://jsfiddle.net/ktq8mb0z/

score:0

half-doughnut, or how I call it, a speedometer graph, is now configured with degrees:

var chart = new Chart(canvas, {
  type: 'doughnut',
  data: ['400', '200'],
  options: {
    rotation: -90,
    circumference: 180,
}

I did this in Chartjs version 3.5.1

score:1

I used this instructions

How can I add some text in the middle of a half doughnut chart in Chart.JS?

some changes for text position and fontsize

var fontSizeToUse = 16;
var centerY = ((chart.chartArea.top + chart.chartArea.bottom) - 80);

http://jsfiddle.net/vencendor/e0c8rgbm/


Related Query

More Query from same tag