Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change the Label Strike-Through with light gray on a ChartJS Doughnut?

I have this ChartJS Doughnut and added an extra Label which will show another value without displaying it on the doughnut. The problem is, ChartJS strikes through labels which are "hidden". Is there a possibilty to change the Strike-Through with a color?

This is my Chart:

This is my Chart

I want it to look like this Chart: The Chart I want it to act like

This is the Source Code:

function donutChart(){    
    var ctx = document.getElementById('can');
    var myChart = new Chart(ctx, {
        type: 'doughnut',
        data: {
            labels: ['Red', 'Blue', 'Yellow', 'Misc'],
            datasets: [{
                label: '# of Votes',
                data: [30, 10, 20],
                backgroundColor: [
                    'rgba(255, 99, 132, 0.2)',
                    'rgba(54, 162, 235, 0.2)',
                    'rgba(126, 214, 223, 0.2)',
                    'rgba(255, 206, 86, 0.2)'
                ],
                borderColor: [
                    'rgba(255, 99, 132, 1)',
                    'rgba(54, 162, 235, 1)',
                    'rgba(126, 214, 223, 1)',
                    'rgba(255, 206, 86, 1)'
                ],
                borderWidth: 1
            }]
        },
        options: {
            legend : {
                display: true,
                position: 'bottom'
            }
        }
    });
}
like image 462
sharpnado Avatar asked Jan 18 '26 11:01

sharpnado


1 Answers

@jordanwillis answer at a similar question solved my problem. Thanks to @jordanwillis and @uminder

The Question: change legend item style when dataset is hidden

like image 160
sharpnado Avatar answered Jan 20 '26 01:01

sharpnado



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!