Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChartJS - Donut charts with multiple rings

Is it possible to create a donut chart with multiple rings using ChartJS as shown below?

multi series donut chart

like image 523
Soni Ali Avatar asked Mar 25 '15 11:03

Soni Ali


2 Answers

You can find out the solution at fiddle link

var ctx = document.getElementById("chart-area").getContext("2d");
var myDoughnut = new Chart(ctx, config);
var config = {
    type: 'doughnut',
    data: {
        datasets: [{
            data: [
               10,20,30
                ],
                backgroundColor: [
                "#F7464A",
                "#46BFBD",
                "#FDB45C"
            ],
        }, {
            data: [
                randomScalingFactor(),
                randomScalingFactor(),
                randomScalingFactor()

            ],
                backgroundColor: [
                "#F7464A",
                "#46BFBD",
                "#FDB45C"
            ],
        }],
        labels: [
            "Red",
            "Green",
            "Yellow"
        ]
    },
    options: {
        responsive: true
    }
};
like image 107
Varun Mittal Avatar answered Sep 22 '22 12:09

Varun Mittal


You need to add multiple datasets into chart. they will be displayed as you need. Please look into their own sample of pie chart. You can download and open it locally as example. There they have multiple datasets, that makes chart look like you need.

Hope that it helped.

like image 35
Matvei Nazaruk Avatar answered Sep 20 '22 12:09

Matvei Nazaruk