PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 15, 2022

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

 July 15, 2022     chart.js, html, javascript, jquery, web-deployment     No comments   

Issue

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'
            }
        }
    });
}

Solution

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

The Question: change legend item style when dataset is hidden



Answered By - Sanako-yan
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing