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

Timeseries off by 1 day #268

Closed
peps opened this issue May 25, 2014 · 10 comments
Closed

Timeseries off by 1 day #268

peps opened this issue May 25, 2014 · 10 comments
Labels
C-bug Category: This is a bug question resolved maybe

Comments

@peps
Copy link

peps commented May 25, 2014

I first ran into this issue on my own project, then noticed that its also happening on the Timeseries Chart example.

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

The chart should start on 2013-01-01 and end 2013-01-06 ... but the chart shows it shifted 1 day into the past. So it starts on 2012-12-31 and ends on 2013-01-05.

This causes the data points to be shown on the wrong dates.

@joshpurvis
Copy link
Contributor

Could this be the issue?
http://c3js.org/samples/axes_x_localtime.html

@peps
Copy link
Author

peps commented May 26, 2014

Yep, that fixed it. Thanks!

Shouldn't that be the default setting? Kinda confusing if the data being passed in doesn't match the graph output. The timezone should be handled on the server side before passing the data in... just my opinion.

@masayuki0812
Copy link
Member

Hi, It seems working well in my environment. Please let me explain..

If localtime = true, the chart is shown correctly.
e.g. If 2013-01-01 specified, 2013-01-01 00:00:00 is shown. The date is NOT converted to UTC.

If localtime = false, the dates are be converted to UTC, so these become -9h because my localtime is +9h from UTC.
e.g. If 2013-01-01 specified, 2012-12-31 15:00 is shown (this is -9h from 2013-01-01). The date is converted to UTC. I think if 2013-01-01 02:00 is shown when localtime is -2h from UTC.

So, I think it would work well with localtime = true. Do you have any idea about this?

@peps
Copy link
Author

peps commented May 27, 2014

It only works for me when localtime = false. Not sure why that is.

It means that for the charts to work properly (in my environment) i must manually set localtime=false.

Im just questioning why the timezone is being converted at all on the client side. Seems like this functionality can be removed, making the code smaller, and the charts just show whatever is passed in... no conversion needed. I cant think of a case where anyone would want UTC conversion on the client side.

@masayuki0812
Copy link
Member

Thanks for the information. Umm.. I'm not sure too why the time is not converted as I expected..

For conversion of time, you're right. The time should not be converted on the client side. (In my environment) c3 does not convert as default. So if it works well, we don't think the timezone on the client side at all.

The case where conversion needed is that the time needs to be shown as the viewer's timezone with same data. It might be rare case though (so, this is not default).

Anyway, I'll keep working on this.

@peps
Copy link
Author

peps commented May 28, 2014

I may have narrowed it down a bit.

On line 2075 in the parseDate function, the __data_x_format variable is undefined. Im passing in the same axis data as the example on the site.

        axis: {
            x: {
                type: 'timeseries',
                tick: {
                    format: '%Y-%m-%d'
                }
            }
        },

The conversion seems to be happening on new Date(date);

Hope this helps, thanks for all the hard work and the amazing library!

@masayuki0812
Copy link
Member

Thank you for your help. I think you're right. Without __data_x_format, the date is not converted properly. I fixed the default of data.x_format not to be converted as a new Date object. It seems working well.

I'll release the next version that includes this fix soon. Thank you!

@peps
Copy link
Author

peps commented May 28, 2014

Amazing work, thank you

@masayuki0812
Copy link
Member

I released 0.2.0 that includes this fix. So I'll close this issue. Thank you.

@arundanegoudar
Copy link

Response From The Server:
{"x":[["2015-07-01"],["2015-07-02"],["2015-07-03"],["2015-07-06"],["2015-07-07"],["2015-07-08"],["2015-07-09"
],["2015-07-10"],["2015-07-11"],["2015-07-13"],["2015-07-14"],["2015-07-15"],["2015-07-16"],["2015-07-17"
],["2015-07-18"],["2015-07-20"],["2015-07-21"],["2015-07-22"],["2015-07-23"],["2015-07-24"],["2015-07-25"
],["2015-07-27"],["2015-07-28"],["2015-07-29"],["2015-07-30"],["2015-07-31"]],"data1":[["20.64"],["20
.35"],["34.1"],["8.19"],["22.19"],["12.77"],["12.81"],["27.22"],["19.87"],["16.03"],["11.24"],["20.39"
],["27.45"],["23.36"],["9.19"],["14.01"],["15.74"],["26.36"],["13.88"],["15.87"],["11.14"],["12.42"]
,["9.19"],["9.83"],["13.59"],["0"]]}

Error: Failed to parse x '2015-07-01' to Date object

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 question resolved maybe
Projects
None yet
Development

No branches or pull requests

4 participants