-
Notifications
You must be signed in to change notification settings - Fork 260
Issues with Y Axis Values & Decimal Values Using Bar Chart #28
Comments
FYI - I've tracked this done to the usage of lodash's range method with floating point values in Axis.js. The difficulties we are dealing with here are documented in this issue from Oct 2015 in the lodash repo. Thinking about possible ways to deal with this. Open to ideas. Plenty of ideas here. My immediate reaction is to work with integers for the range values (and then convert back). |
Ok, I'm looking for some design feedback before starting a PR on this one. I generally think the "Method 3" technique offered here is usable to solve the issue. The only question in my mind is how do you determine what a suitable default for the number of decimal places to target (and therefore shift to the left of the decimal point to round before converting back to the target number of decimal places)? Here's a jsfiddle to illustrate the issue - how does one specify the
A lot of this feels like a big hack and all of these approaches are problematic in various regards so I'm trying to pick the one that "sucks the least". Any thoughts? Any approaches I haven't considered here that are better? |
The |
What about a format function that can be overridden? Use a default with perhaps 2 decimal places, but otherwise allow a user to format however they like (such as with currency symbols). That would be the most robust. |
The "format function" already exists here and is embodied in the While its true each user of this library could address the floating point problem in this issue by implementing their own rounding routine in that labelFunction function, I think this is a more universal problem that occurs often enough that we would want to address it for everyone. |
There's an issue with the scale return for the Y axis values when using decimal numbers.
When the scale is from 0-0.5, 0.3 on Y axis is rendered as 0.30000000000000004
When the scale is from 0-1, 0.6 is rendered as 0.6000000000000001 on the Y axis.
The text was updated successfully, but these errors were encountered: