Set min, max and number of steps in the radar chart. Js

I am using chartjs.org 2.2.1 and have a radar chart that has values ​​between 1..5. I want to set the min value to 0 and max 5 in increments of 1.

This seems to have exactly answered the SO post here. However, my charts still have a weird scale, not the one I defined according to my code below.

Can anyone see what I'm doing wrong here?

var options = { responsive: false, maintainAspectRatio: true }; var dataLiteracy = { labels: [ @PointLabel("Literacy", 1), @PointLabel("Literacy", 2), @PointLabel("Literacy", 3), @PointLabel("Literacy", 4), @PointLabel("Literacy", 5) ], datasets: [ { label: "Literacy", backgroundColor: "rgba(179,181,198,0.2)", borderColor: "rgba(179,181,198,1)", pointBackgroundColor: "rgba(179,181,198,1)", pointBorderColor: "#fff", pointHoverBackgroundColor: "#fff", pointHoverBorderColor: "rgba(179,181,198,1)", data: [ @PointValue("Literacy", 1), @PointValue("Literacy", 2), @PointValue("Literacy", 3), @PointValue("Literacy", 4), @PointValue("Literacy", 5) ] } ] }; var ctx = $("#chartLiteracy"); var myRadarChart = new Chart(ctx, { type: 'radar', data: dataLiteracy, options: options, scaleOverride: true, scaleSteps: 5, scaleStepWidth: 1, scaleStartValue: 0 }); 
+11
source share
2 answers

You are right, but only if you use Chart.js v1.x.

Ticks options have changed in v2.x (the one you are using).


If you want to edit the radar labels, you will need to edit the ticks attribute in the chart parameters:
 var options = { scale: { ticks: { // changes here } } }; 

From what you need (enter a scale from 0 to 5), you can:

  • set the beginAtZero attribute to true and max to 5
  • set the min attribute to 0 and max to 5

You can see the result here .

+30
source

Set value to stepSize

 scale: { ticks: { beginAtZero: true, max: 5, min: 0, stepSize: 1 } } 
0
source

All Articles