Chartjs-Changing borderDash for specific gridLines in radar chart

0👍

You can already use Chart.js version 3, it’s available as Chart.js 3.0.0-beta.

Simply add the following script tag to your HTML page.

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.0.0-beta/chart.min.js"></script>

Please take a look at the following code snippet and see how it works.

new Chart("radar-chart", {
  type: 'radar',
  data: {
    labels: ["A", "B", "C", "D", "E"],
    datasets: [{
      data: [25.48, 54.16, 7.61, 8.06, 4.45],
      backgroundColor: "rgba(255,99,132,0.2)",
      borderColor: "rgba(255,99,132,1)"
    }]
  },
  options: {
    legend: {
      display: false
    },
    scale: {
      ticks: {
        min: 0,
        max: 60,
        stepSize: 10
      },
      gridLines: {
        lineWidth: 2,
        color: "lightgreen",
        borderDash: context => context.index == 6 ? [] : [6, 4]
      }
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.0.0-beta/chart.min.js"></script>
<canvas id="radar-chart" height="120"></canvas>

Leave a comment