Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force yaxis to start at 0 #302

Closed
elbojoloco opened this issue Feb 5, 2019 · 6 comments
Closed

Force yaxis to start at 0 #302

elbojoloco opened this issue Feb 5, 2019 · 6 comments

Comments

@elbojoloco
Copy link

elbojoloco commented Feb 5, 2019

Is your feature request related to a problem? Please describe.
I'm making a chart where the data becomes hard to understand when it doesn't start at 0.

Describe the solution you'd like
Add an option (like yaxis.startAtZero: true|false) to force the chart to start drawing at 0.

Describe alternatives you've considered
none

Additional context
Seems like a pretty simple fix, in the part where it decides to not start at 0, do it only when the option is set to false.

@junedchhipa
Copy link
Contributor

Have you tried yaxis.min: 0 ?

@elbojoloco
Copy link
Author

That does exactly what I needed, it does give some weird numbers in the yaxis though. How do I use this while still maintaining nice and round numbers?
image

@junedchhipa
Copy link
Contributor

  yaxis: {
    labels: {
      formatter: function(val, index) {
        return Math.round(val);
      }
    }
  }

@elbojoloco
Copy link
Author

I mean round like 150 instead of 166 and 420 instead of 416 for example, like the default behavior

@junedchhipa
Copy link
Contributor

I just realized this is not possible currently. Thanks for pointing it out.
Fixed it. Will be available in the next patch release.

@junedchhipa
Copy link
Contributor

The new property will be

yaxis: {
  forceNiceScale: true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants