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

Top of graph is cut off when values are specified as strings #841

Closed
sarah-clements opened this issue Mar 29, 2018 · 12 comments
Closed

Top of graph is cut off when values are specified as strings #841

sarah-clements opened this issue Mar 29, 2018 · 12 comments
Labels

Comments

@sarah-clements
Copy link

This only happens if I use data with two decimals. The highest value for this example is 22.00. Is there a work-around for this?

screen shot 2018-03-29 at 4 31 48 pm

@sarah-clements sarah-clements changed the title Top of chart is cut off on certain graphs when using decimals Top of graphis cut off when using decimals Mar 29, 2018
@sarah-clements sarah-clements changed the title Top of graphis cut off when using decimals Top of graph is cut off when using decimals Mar 29, 2018
@wlach
Copy link
Collaborator

wlach commented Mar 30, 2018

This just sounds like a bug, maybe in the axis scaling code? If you have time to look into it, we've fixed a bunch of similar things recently if you look at the commit log. Otherwise I can try to find some time to take a peek next week.

@wlach
Copy link
Collaborator

wlach commented Mar 30, 2018

btw, a reproducible test case on jsfiddle using the latest version would be helpful, see for example #838

@wlach wlach added the bug label Mar 30, 2018
@sarah-clements
Copy link
Author

Here's a fiddle showing the problem.

@wlach
Copy link
Collaborator

wlach commented Apr 4, 2018

The problem here seems to be that you're specifying the values as strings, if I change the value "20.0" in your example to 20.0 the axis seems to scale as expected;

https://jsfiddle.net/n5u2wwjg/7372/

That said, we should fix the axis scaling code to accept values passed in as strings (probably by trying to coerce them into numbers).

@wlach wlach changed the title Top of graph is cut off when using decimals Top of graph is cut off when values are specified as strings Apr 4, 2018
wlach added a commit to wlach/metrics-graphics that referenced this issue Apr 4, 2018
@sarah-clements
Copy link
Author

It does, but if you remove the "" from all of the values in the fiddle, the labels display the numbers as integers - not decimals. Interestingly, here's another example where the values are represented as either numbers or strings. If you change one number to be an outlier, say 10.72, the values represented as strings show decimals correctly and the values represented as numbers are rounded.

Either way, I don't think there's a work-around to using a method like .toFixed() to display decimals when using division (which returns a string).

@wlach
Copy link
Collaborator

wlach commented Apr 4, 2018

You might coincidentally get the behavior you expect some of the time with strings and that function, it depends on what you pass in. In the first example you posted, "8.72" resolves to be greater than "20.0" (as a string), so it gets classified as the maximum.

It doesn't surprise me to hear that there are some issues with formatting values for display on the legend. Please file bugs for what you see and we can try to address them (@openjck has been filing some issues for some similar things, so maybe check the issues list first).

@sarah-clements
Copy link
Author

Sure, I can file another bug. To be clear: you think the labels showing numbers being incorrectly rounded is unrelated to this original problem, which is the result of strings - rather than numbers - being provided (and the workaround in the meantime is not to use strings)?

@wlach
Copy link
Collaborator

wlach commented Apr 4, 2018

@sarah-clements I'm pretty sure that these are two seperate problems, yeah. #843 should fix the axis scaling issues when strings are passed in.

@sarah-clements
Copy link
Author

Ok, thanks for looking into this!

@openjck
Copy link
Contributor

openjck commented Apr 4, 2018

Is this related to #823?

@wlach
Copy link
Collaborator

wlach commented Apr 4, 2018

@openjck no that looks different, as we're seeing that bug when the values are specified as integers.

@wlach
Copy link
Collaborator

wlach commented Apr 9, 2018

Ok, after discussing this with @hamilton and @sarah-clements, I think what we really want is to fix #844 -- that was the motivation for using strings instead of numbers in the first place. Closing this one.

@wlach wlach closed this as completed Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants