Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EmilMoe's avatar
Level 10

ChartJS and "half donuts"

Before I procedure with this amazing chart library, I want to be sure that it supports half donuts. Sorry I don't know the explicit name of them, gauge charts?

Can it achieve that?

alt

0 likes
7 replies
EmilMoe's avatar
Level 10

Thanks, I know it supports the full round, but can I easily make the half? :-) I assume someone in here tried and can give feedback on that.

tomopongrac's avatar

@EmilMoe

Here is code

https://jsfiddle.net/z638ttv0/

html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <canvas id="myChart" width="400" height="400"></canvas>
  

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.min.js"></script>

</body>
</html>

JavaScript

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
    }
});
1 like
EmilMoe's avatar
Level 10

Ah perfect, haha.. I just looked quickly through the examples.

1 like
Sangita.Jadhav's avatar

Hi guys I using sujithlaracast solution for half donuts graph I want to repeat that half donuts 2 times for 3 wights total i want 6 half donuts. how i achive that please give me solution for that I using angularjs.

Please or to participate in this conversation.