I'm currently working on an app that is using the annotated timeline
chart. We added a listener for the rangechange event, which seems to
work, but the start and end dates returned by the chart seem a little
strange. For instance, when I zoom the chart to November 3rd as the
start date, the listener (chartname.getVisibleChartRange.start)
reports November 1st (plus an hh:mm:ss component). Sometimes the
start date is right on, sometimes it is off by one or two days. I'm
executing some ajax to return data based on the timeline zoom, so a
day or two difference can result in a completely different dataset.
I understand that timezones come into play here (I'm in CST... -5 or 6
depending on daylight savings), but I'm not sure why the dates are off
by up to 2 days. To test this, I went to the google code playground
and added a listener to the sample:
Sample url: http://code.google.com/apis/ajax/playground/?type=visualization#annotated_time_line
Listener I added:
google.visualization.events.addListener(annotatedtimeline,
'rangechange', function(){
console.log('Start: ' +
annotatedtimeline.getVisibleChartRange().start);
});
You can observe the same date behavior on this playground that I see
locally: I chose Feb 3rd - Feb 6th (specifically, the first point
where the legend (at the top of the chart) showed Feb 3rd as the start
point). I expected to see Feb 3rd with some time component but
instead saw Fri Feb 01 2008 12:22:39 GMT-0600 (Central Standard
Time). This seems like a bug. Am I missing something?
Is this a timezone issue? I can't see how, considering I'm CST, which
is - 5/6 hours; that doesn't resolve the (sometimes) 36 hour
discrepancy I'm seeing put into the console. Again, I wonder if I'm
missing something or being a bit thick?
Thanks
Bob
I actually see the same behavior in your example on fiddle as in the
google code playground (and our site). I think my point isn't coming
across correctly; when I say the date legend, I'm talking about the
range of dates that appears at the very top of the graph, next to the
text that reads: "Sold Pencils {some number}" and "Sold Pens {some
number}". If you watch that date range when sliding the zoom control,
and use that to pick Feb 3rd (as our users do), the date that is
logged (for us) is Feb 01. Our users are using that legend to select
an appropriate range for a graph that shows 1 year's worth of data.
Aligning the zoom control under the x-axis is pretty inaccurate when
you're dealing with 6 mo - 1 year worth of data.
Here are some screenshots to illustrate:
What I've chosen, with the text of the legend: http://f.imgtmp.com/HLc16.png
What is output in console: http://f.imgtmp.com/FHltz.png
Thanks
Bob