Sorry, my mistake.  This use of the string format for dates and datetimes
has not ever worked when used with the addRows() method.  If you need to
pass date strings, you will need to use the actual strict json
representation shown in the example here:
https://developers.google.com/chart/interactive/docs/datesandtimes#dates-and-times-using-the-date-string-representation

This is because the only reason you need to use this string representation
of dates and datetimes is for json which doesn't permit the 'new' keyword
to construct dates.  For consistency, I expect we should be able to support
this same format in other cases as well.

For reference, also see:
https://developers.google.com/chart/interactive/docs/datatables_dataviews#creating-and-populating-a-datatable



On Wed, Mar 15, 2017 at 9:19 AM, Daniel LaLiberte <[email protected]>
wrote:

> Thanks for reporting this.  For some reason, the string notation for dates
> and datetimes is not working.  Until we fix it, you will have to use
> JavaScript date constructors.  e.g. new Date(2017, 2, 17, 10, 49, 21)
> without the quotes.
>
>
> On Wed, Mar 15, 2017 at 8:07 AM, Dmitry Tumannik <[email protected]>
> wrote:
>
>> Hello.
>> I'm in trouble with that.
>>
>> function drawChart() {
>>
>> var chart = new 
>> google.visualization.AnnotationChart(document.getElementById('chart_div'));
>>
>> function updateData () {
>>    $.ajax({
>>       url: 'getData.php',
>>       dataType: 'json',
>>       success: function (json) {
>>          data = new google.visualization.DataTable(json);
>>          data.addColumn('datetime', 'Date');
>>          data.addColumn('number', 'Number');
>>          data.addRows(json);
>>          chart.draw(data);
>>       },
>>       error: function() {
>>          console.log('nodata');
>>       }
>>    });
>> }
>>
>> setTimeout(function () {
>>    updateData();
>> }, 1000);
>>
>> }
>>
>>
>> getData:
>>
>> $string = file_get_contents("testData.json");
>> echo $string;
>>
>>
>> JSON:
>>
>> [
>> ["Date(2017, 2, 17, 10, 49, 21)",386],["Date(2017, 2, 17, 10, 51, 
>> 15)",452],["Date(2017, 2, 17, 10, 50, 35)",327]
>> ]
>>
>>
>> What I am doing wrong?
>>
>> --
>> 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 google-visualization-api@googl
>> egroups.com.
>> Visit this group at https://groups.google.com/grou
>> p/google-visualization-api.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/google-visualization-api/73de14b5-efd2-4f16-9b2d-43921b
>> 83956a%40googlegroups.com
>> <https://groups.google.com/d/msgid/google-visualization-api/73de14b5-efd2-4f16-9b2d-43921b83956a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
> [email protected] <[email protected]>   5CC, Cambridge MA
>



-- 
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
[email protected] <[email protected]>   5CC, Cambridge MA

-- 
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJPjhaF0WR2rxawWeJR788q3-ix6owa0S0jNUKbzMGB%2BhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to