Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Doughnut spacing

I am trying to achieve effect similar to this
doughnut example
hoping to have each piece spaced out from other and if possible rounded out edges
I’m fairly new to chartjs so I haven’t had much luck finding some answers related to it

Here is my current js code for the chart

    const labelsd = <?php echo $jswallet;?>;
    const data = {
        labels: labelsd,
        datasets: [
        {
            label: "Wallets",
            data: <?php echo $jsamount;?>,
            backgroundColor: [
                "#1D7A46",
                "#C724B1",
                "#c7243f",
                "#0E75F1",
                "#2E8B57"
            ],
            borderColor: [
                "#1D7A46",
                "#C724B1",
                "#c7243f",
                "#0E75F1",
                "#1D7A46"
            ],
            borderWidth: [1, 1, 1, 1, 1]
        }
        ]
    };
    const config = {
        type: 'doughnut',
        data: data,
        options: {
            cutout: 140,
            responsive: true,
            plugins: {
                legend:{display: false},
                title: {display: false,}
            }
        },
    };
    const minutedownloads = new Chart(
        document.getElementById('dailyspendings'),
        config
    );

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In your graph options, set cutout: "95%" and borderRadius: 3 like this

const labelsd = <?php echo $jswallet;?>;
const data = {
    labels: labelsd,
    datasets: [
    {
        label: "Wallets",
        data: <?php echo $jsamount;?>,
        backgroundColor: [
            "#1D7A46",
            "#C724B1",
            "#c7243f",
            "#0E75F1",
            "#2E8B57"
        ],
        borderColor: [
            "#1D7A46",
            "#C724B1",
            "#c7243f",
            "#0E75F1",
            "#1D7A46"
        ],
        borderWidth: [1, 1, 1, 1, 1]
    }
    ]
};
const config = {
    type: 'doughnut',
    data: data,
    options: {
        cutout: "95%",
        borderRadius: 3,
        responsive: true,
        plugins: {
            legend:{display: false},
            title: {display: false,}
        }
    },
};
const minutedownloads = new Chart(
    document.getElementById('dailyspendings'),
    config
);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading