-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I've found the issue #797, but it's labelled as a feature request, while I think the problem is rather a bug. A similar case was described in #1261 and in a closed question #1654 and also in #1639.
I can reproduce my case with this simple code:
var chart = c3.generate({
data: {
columns: [
['data', 0.15, 0.5]
]
}
});
I simply paste it replacing in any of the examples code. In Firefox (51.0.1) and Chrome (56.0.2924.87) one of the Y axis tick labels shows up as "0.15000000000000002" (instead of "0.15"). In IE (11.0.9600.18537CO) it's shown correctly.
I'm aware that I can simply set up the X axis tick format to a 2 decimal digit precision (e.g.: d3.format('.2f')), but it's not a solution in my case, as I want the tick precision shown to adapt to the data passed, which does not have any arbitrary precision, e.g. it would not make sense to have a fixed 2-digit precision, if the data points are 0.015 and 0.05 (I'd get repeating and misleading Y-axis tick labels).
As the chart automatically determines the most appropriate step between ticks (in this case it's 0.05), it should also be able to determine the appropriate precision to show them and apply the correct formatting (unless one was provided). It should also work, if tick values are also explicitly provided (but the format is not).
As a workaround, I would have to analyze the data points I have, to determine the tick step on my own (and provide a format based on that step) and probably also, based on that step, calculate all the tick values, so I can be sure that the chart will not use some other step. This basically means recreating a part of the chart functionality.