javascriptjquerychart.jsradar-chart

chart js radar chart make axes thicker


I have a radar chart with chart.js in MVC Core.net 6.

This is my code:

var options = {
    scale: { 
       ticks: { 
       max: 100,
       beginAtZero: true,
       stepSize: 20,
       display: false
       } ,
   },                      
   tooltips: {                          
      callbacks: {
         label: function (tooltipItem, data,) {
             var questionNum =Math.ceil((tooltipItem.yLabel * gtotal[tooltipItem['index']]) / 100);                              
             return  data.datasets[tooltipItem.datasetIndex].label + ": " + questionNum +" From" + gtotal[tooltipItem['index']];                        
           }
     }
   },
    scaleSteps: 5,
    scaleStartValue: 1
  };

 var myRadar =new Chart(ctx, {
                   type: 'radar',
                   data: ChartData,
                   options: options
               });

Current output:

enter image description here

How can I make the axes thicker?


Solution

  • Per the doco, you need to set:

    For the 'spokes' of the chart:

    options.scales.r.angleLines.lineWidth
    

    And, for the lines connecting the 'spokes':

    options.scales.r.grid.lineWidth
    

    See below for an example:

    var options = {
      elements: {
        line: {
          borderWidth: 3
        }
      },
      scales: {
        r: {
          grid: {
            lineWidth: 4
          },
          angleLines: {
            lineWidth: 6
          }
        }
      }
    };
    
    var myRadar = new Chart(ctx, {
      type: 'radar',
      data: ChartData,
      options: options
    });
    <div>
      <canvas id="myChart"></canvas>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
    var ctx = document.getElementById('myChart');
    
    var ChartData = {
      labels: [
        'Eating',
        'Drinking',
        'Sleeping',
        'Designing',
        'Coding',
        'Cycling',
        'Running'
      ],
      datasets: [{
        label: 'My First Dataset',
        data: [65, 59, 90, 81, 56, 55, 40],
        fill: true,
        backgroundColor: 'rgba(255, 99, 132, 0.2)',
        borderColor: 'rgb(255, 99, 132)',
        pointBackgroundColor: 'rgb(255, 99, 132)',
        pointBorderColor: '#fff',
        pointHoverBackgroundColor: '#fff',
        pointHoverBorderColor: 'rgb(255, 99, 132)'
      }, {
        label: 'My Second Dataset',
        data: [28, 48, 40, 19, 96, 27, 100],
        fill: true,
        backgroundColor: 'rgba(54, 162, 235, 0.2)',
        borderColor: 'rgb(54, 162, 235)',
        pointBackgroundColor: 'rgb(54, 162, 235)',
        pointBorderColor: '#fff',
        pointHoverBackgroundColor: '#fff',
        pointHoverBorderColor: 'rgb(54, 162, 235)'
      }]
    };
    </script>