简体   繁体   中英

ChartJS Polar Area Chart Scale Removing

I'm trying to use a Polar Area Chart and I'm not managing to remove the circular lines from it. I've tried with the diplay property of scales and also with the schaleShowLine property but nothing worked. Here is the reference from the official website http://www.chartjs.org/docs/#polar-area-chart

$(document).ready(function(){
var ctx = document.getElementById("myChart").getContext("2d");

         Chart.defaults.global.legend.display = false;


        var myLineChart = new Chart(ctx, {
    type: 'polarArea',
    data:{
    datasets: [{
        data: [
            100,
            100,
            90,
            50,
            53
        ],
        backgroundColor: [
            "#FF6384",
            "#4BC0C0",
            "#FFCE56",
            "#E7E9ED",
            "#36A2EB"
        ],
        label: 'My dataset' // for legend
    }],
    labels: [
        "asdfasdf",
        "adsfasdf",
        "asdffdgdfg",
        "sdfgsdfgsd",
        "sdfgsdfgsdf"
    ]
},
        options:{
            scales: {
                scaleShowLine:false,
                display:false,
            },
            tooltips:{
                enabled:false,
            }




        },    



            animation:{
                animateScale:true
            },


});

     });

The property you need to edit is actually in scale and not scales as you did (and as you do with other chart types) :

var options = {
    scale: {
        display: false
    }
};

And this will give you this result .

What worked for my case (chart.js v3.7.1) was:

var options = {
  scales: {
    r: {
      display: false
    }
  }
}

PolarArea chart uses RadialLinearScale. So, as the documentation states here the display: none property should go to the axis id (options.scales[scaleId]) and the axis id for RadialLinearScale is r .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM