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

xFormat not parsing date correctly #943

Closed
pensierinmusica opened this issue Jan 27, 2015 · 6 comments
Closed

xFormat not parsing date correctly #943

pensierinmusica opened this issue Jan 27, 2015 · 6 comments
Labels
C-bug Category: This is a bug resolved maybe

Comments

@pensierinmusica
Copy link

Hi,

With this data and configuartion it looks like C3 is not parsing the dates correctly:

var chart = c3.generate({
  height: 300,
  bindto: '#c3-chart',
  data: {
    x: 'date',
    xFormat: '%Y%m%d',
    rows: [
      ['date', 'price'],
      ['20140915', 50],
      ['20140916', 20],
      ['20140917', 10],
      ['20140918', 40],
      ['20140919', 15],
      ['20140920', 25]
    ]
  },
  axis: {
    x: {
      type: 'timeseries',
      tick: {
        format: '%Y-%m-%d'
      }
    }
  }
});

I made a quick JS fiddle to show what I mean.

Can you please check if I'm doing something wrong, or if it's a bug?

Thanks!

@bendrexl
Copy link

bendrexl commented Feb 4, 2015

It seems to be broken in the c3.js "Timeseries" example as well (by uncommenting the xFormat and corresponding 'x' row in the data) - all dates show 1969-12-31

http://c3js.org/samples/timeseries.html

@masayuki0812
Copy link
Member

Thank you for reporting. This a bug and c3 was not able to handle string data correctly. A string that can be converted to number (e.g. 20150101) was treated as unixtime, so I modified to always parse string date by using xFormat and treat x as unixtime only when it's a number.
I think now it's ok and I'll release this fix in the next version 0.4.10. Thanks.

@masayuki0812
Copy link
Member

0.4.10 has been released, so let me close at the moment. Thanks.

@jeremyshawnjackson
Copy link

Has this bug been resolved? I'm experiencing the same error with the code here http://jsfiddle.net/ertdnh2m/2/

@masayuki0812
Copy link
Member

Thank you for reporting, but I found this happens because date values are given as number, not string. Can you see this fiddle (http://jsfiddle.net/ertdnh2m/4/) which I updated to give date values as string.

Btw, I don't think date values as number should not be handled as date format string nicely because date values as number (e.g. 1431267484058) can be given already. So, I'd like to keep current behaviour at the moment.

@samskrithib
Copy link

samskrithib commented Feb 20, 2017

C3js not converting Unix time stamp properly.

http://jsfiddle.net/j9xs7ram/
See the second value "1486456770000" on-hover it shows ":30"
@masayuki0812 Can you please help me how to solve this?

Many Thanks in advance.

I solved it by changing the tooltip format.
Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug resolved maybe
Projects
None yet
Development

No branches or pull requests

5 participants