question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BeginAtZero and stepsize not working on radar chart

See original GitHub issue

I want to show only integers in labels of a radar chart. I check many solutions i found on here and stackoverflow. I set stepsize:1 and seems is doing nothing… when max scale value is 1 or 2 it show many float values like 0.2,0.4,0.6… Also, i check this:

userCallback: function(label, index, labels) {
                           // when the floored value is the same as the value we have a whole number
                           if (Math.floor(label) === label) {
                               return label;
                           }
}        

and is not working.

Also i set min:0 on my scale. But when every value of my chart is 0, scale is between -1 and 1.

Not sure if this an issue or im doing something wrong.

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
etimbergcommented, May 18, 2017

@borjaevo the issue here was that the config was incorrect. It should be

options: {
    scale: {
        ticks: {
            beginAtZero: true,
            min: 0,
            userCallback: function(label, index, labels) {
                // when the floored value is the same as the value we have a whole number
                if (Math.floor(label) === label) {
                    return label;
                }
            },
        }
    }
}
1reaction
borjaevocommented, May 3, 2017

Hi,

Version is 2.5.0.

This is the code:

` var hourlyActChart = new Chart(ctx, {

     type: 'radar',

     data: data,

     options: {

         scales: {
            scale: {
                ticks: {
                    beginAtZero: true,
                    min: 0,
                    userCallback: function(label, index, labels) {
                       // when the floored value is the same as the value we have a whole number
                       if (Math.floor(label) === label) {
                           return label;
                       }
                   },
                }
            }
        }
    }
 })

`

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

ChartJS - radar chart options not working - Stack Overflow
I am using the latest version of chart.
Read more >
Radar Chart | Chart.js
A radar chart is a way of showing multiple data points and the variation between them. They are often useful for comparing the...
Read more >
Getting Started With Chart.js: Axes and Scales - Code Tutsplus
In this tutorial, you will learn how to manipulate scales and control their appearance using different options that the library provides.
Read more >
Change axis value for polararea chart - Prime Community Forum
Dear Team, I have p:polarAreaChart chart in my application and I use Primefaces primefaces-7.0.RC1 with JSF2.
Read more >
Linear Radial Axis - Git ECE IASTATE
The linear scale is use to chart numerical data. ... chart outward from the center), pointLabels (labels around the edge in a radar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found