Export to GitHub

dygraphs - issue #255

date supplied as YYYY-MM-DD is shows with previous days date on mouseover


Posted on Jan 10, 2012 by Helpful Panda

Please look at the basic example graph on http://dygraphs.com,

On hovering the mouse cursor over any data point in the graph, the date displayed is less by 1 day.

This error does not occur when the date is specified as YYYYMMDD.

I'm using chrome browser on linux.

I've copied the code from dygraphs.com and pasted it here.


<html> <head> <script type="text/javascript" src="dygraph-combined.js"></script> </head> <body> <div id="graphdiv"></div> <script type="text/javascript"> g = new Dygraph(

// containing div
document.getElementById(&quot;graphdiv&quot;),

// CSV or path to a CSV file.
&quot;Date,Temperature\n&quot; +
&quot;2008-05-07,75\n&quot; +
&quot;2008-05-08,70\n&quot; +
&quot;2008-05-09,80\n&quot;

); </script> </body> </html>

Comment #1

Posted on Jan 23, 2012 by Quick Elephant

I believe this is a time zone issue -- it shows up at 8 PM for me.

Comment #2

Posted on Feb 8, 2012 by Helpful Giraffe

I would really like to be able to opt out of this and have YYYY-MM-DD dates from the CSV show unchanged on the graph.

Use case: http://people.mozilla.org/~bjacob/gfx_features_stats

Thanks for Dygraph by the way!

Comment #3

Posted on Mar 13, 2012 by Quick Elephant

FYI, this has now been fixed: https://github.com/danvk/dygraphs/commit/3f675fe524eece31f39fb68601d2d2d7d5720941

this bug was introduced here: https://github.com/danvk/dygraphs/commit/769e8bc7b8799385e2677b26a5c0a72e839f44ca

The issue is that new Date("2012/03/13") and new Date("2012-03-13") use local time and UTC, respectively. JavaScript date parsing is ridiculous.

Status: Fixed

Labels:
Type-Defect Priority-Medium