C3 Chart yAxis show extraneously long decimal points
To reproduce, use the following snippet
var chart = c3.generate({
data: {
columns: [
['data1', 0.1, 0.05, -0.3]
]
}
});
setTimeout(function () {
chart.axis.range({
min: { y: -0.3 }, max: { y: 0.1 } // -0.6 and -0.7 has the same issue with decimal points
})
}, 750);
Notice all the numbers have extraneously long numbers after the decimal points.

Floating point operations (which is what the axis code is doing interpolating between two values) often show rounding errors, try typing 0.1+0.2 into a javascript console...
Here though, you just need to use an appropriate formatter on the y ticks:
axis: {
y: {
tick: {
format: d3.format('.2f')
}
}
}
Thanks, @martingraham Our charts need to display wide range of data, some times the numbers need to be formatted differently depending on the set. I cannot find a way to update tick marks dynamically once the chart is generated, do you happen to know how to update the tick/format function dynamically in C3?
You can write custom method to format number based on set
axis : {
y : {
tick : {
format: function(d){return cutShortNumber(d)}
}
}
}
cut short the number in that function and return it.
closing in favor of #797