Alright, I know the problem occurs in my time zone (UTC+1) but I'm not sure 
if the problem happens in every time zone. Because it is a very specific 
problem. Below you can find a screenshot of the plunker in my situation.

<https://lh5.googleusercontent.com/-zN8_eMtgJNE/U46-14IXMbI/AAAAAAAADJw/gFPXcdOP5EA/s1600/Capture.PNG>


On Wednesday, June 4, 2014 4:09:41 AM UTC+2, Andrew Gallant wrote:
>
> No, I cannot replicate the error.  Could you build another plunker that 
> demonstrates the problem?
>
> On Tuesday, June 3, 2014 2:54:45 AM UTC-4, Stef Coenen wrote:
>>
>> Thanks for your answer. I have applied your code sample to the full code 
>> and I am sure this will be a better approach to converting dates in string 
>> to objects but I keep receiving the same error message that just isn't very 
>> helpfull. Could it be that this is a bug the api?
>>
>> Can you reproduce the error, or do you need additional information?
>>
>> On Monday, June 2, 2014 6:40:50 PM UTC+2, Andrew Gallant wrote:
>>>
>>> Creating dates from strings is a bad idea.  Each browser parsing strings 
>>> a bit differently, and thus they won't all generate the same date given the 
>>> same string.  You should manually parse your strings and then build date 
>>> objects from them:
>>>
>>> var dateStr = '2014-03-30T01:30:00+01:00';
>>> var dateArr = 
>>> dateStr.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/);
>>> var year = parseInt(dateArr[1]);
>>> var month = parseInt(dateArr[2]) - 1; // convert month to javascript's 
>>> 0-indexed months
>>> var day = parseInt(dateArr[3]);
>>> var hours = parseInt(dateArr[4]);
>>> var minutes = parseInt(dateArr[5]);
>>> var seconds = parseInt(dateArr[6]);
>>>
>>> var date = new Date(year, month, day, hours, minutes, seconds);
>>>
>>> Javascript does not handle timezones well, as all dates are created in 
>>> the browser's locale time (except for some browsers when creating dates 
>>> from strings).  If you need to account for timezone differences, you can 
>>> pull the offset data from your date strings as well, modify the 
>>> hours/minutes to get to UTC time, and then get the browser's timezone 
>>> offset and adjust them again to change your dates to local time.
>>>
>>>
>>> On Monday, June 2, 2014 10:26:00 AM UTC-4, Stef Coenen wrote:
>>>>
>>>> Hi, we are creating an web application that displays a chart of 
>>>> electricity meters data. We receive it in the form of a json array and 
>>>> parse it into regular JavaScript date objects and values. We use the 
>>>> Google 
>>>> visualization api for displaying this data.
>>>>
>>>> Everything works as expected, only when we request data from the 30th 
>>>> March we receive an "error" (as returned by Google chart). The following 
>>>> code is a simplified version where dataTable 'data' is creating the error 
>>>> and the dataTable 'datab' is not creating any errors:
>>>>
>>>>> function drawVisualization() {
>>>>>   // Some raw data (not necessarily accurate)
>>>>>   var data = google.visualization.arrayToDataTable([
>>>>>     ['Sequence', 'Usage'],
>>>>>     [new Date("2014-03-30T01:30:00+01:00"), 10],
>>>>>     [new Date("2014-03-30T01:45:00+01:00"), 135],
>>>>>     [new Date("2014-03-30T03:00:00+02:00"), 157],
>>>>>     [new Date("2014-03-30T03:15:00+02:00"), 139],
>>>>>     [new Date("2014-03-30T03:30:00+02:00"), 136]
>>>>>   ]);
>>>>>
>>>>>   var datab = google.visualization.arrayToDataTable([
>>>>>     ['Sequence', 'Usage'],
>>>>>     [new Date("2014-03-30T01:30:00+01:00"), 10],
>>>>>     [new Date("2014-03-30T01:45:00+01:00"), 135]
>>>>>   ]);
>>>>>
>>>>>   // Create and draw the visualization.
>>>>>   var ac = new 
>>>>> google.visualization.AreaChart(document.getElementById('visualization'));
>>>>>   ac.draw(data, {
>>>>>     title: 'Electricity usage',
>>>>>     isStacked: true,
>>>>>     width: 600,
>>>>>     height: 400
>>>>>   });}
>>>>>
>>>>> google.setOnLoadCallback(drawVisualization);
>>>>>
>>>>> A plnkr of this code can be found on the following link: link 
>>>> <http://plnkr.co/edit/S2H4Qx8NChgT59caIJXf?p=preview> Please keep in 
>>>> mind that I am located in UTC+1 and the error might not show in all time 
>>>> zones.
>>>> Thanks
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to