Open jonashaag opened 9 years ago
How can we fix this?
I had the same issue but I fixed my data, I don't think the graphing library should take care of these things. It should just plot whatever you give it.
Unless you have a scenario that I have missed.
I disagree. I'm getting some labels that are correct and some that are showing floating point problems:
It's not the data's fault, the data looks like:
{
_id: "573a3743f6e91aa6b86a881d",
status: "g",
dt: 1463433027504,
time: 2.8683171272278
},
{
_id: "573a374db23965e6eb42ca00",
status: "g",
dt: 1463433037064,
time: 2.8683171272278
},
{
_id: "573a375cb23965e6eb42ca14",
status: "g",
dt: 1463433052072,
time: 2.8683171272278
},
{
_id: "573a376bb23965e6eb42ca20",
status: "g",
dt: 1463433067104,
time: 2.4415690898895
},
{
_id: "573a377ab23965e6eb42ca36",
status: "g",
dt: 1463433082114,
time: 2.4415690898895
},
{
_id: "573a377ff6e91aa6b86a882f",
status: "g",
dt: 1463433087525,
time: 2.4415690898895
},
{
_id: "573a3789b23965e6eb42ca47",
status: "g",
dt: 1463433097093,
time: 2.4415690898895
},
@masayuki0812 This looks like a bug to me, not an enhancement.
hiw about adding default d3.format?
I don't know if that will work, long-term, since the data coming in can vary a lot (sometimes it's decimal, sometimes it'll be integers).
I set the y axis format to d3.format(".3n")
and it seems to be helping. Hard to say though since the error doesn't show up very often.
C3 should take care of floating point rounding imprecision, i.e. values like "0.30000000000000004" (= 0.1 + 0.2), in X and Y axis ticks.
We could
Someone already reported this in #506, but no action was taken there to resolve the problem.
I think that this should be taken care of in c3, because it's a common problem (anyone dealing with floating point values is exposed to it).