I was able to make this work by parsing it manually from the string in JS 
and creating a Date object properly. 

Still seems super buggy to pass in an ISO8601 datetime string that's 
syntactically correct, and the library to respond that it's not of the 
correct format. 



On Wednesday, June 6, 2018 at 10:07:47 PM UTC-4, Wes Melton wrote:
>
> In the example given in the Line Chart documentation, it shows that you 
> can use the helper methods (addColumn & addRow) instead of creating a 
> formal datatable. 
>
>    var data = new google.visualization.DataTable();
>       data.addColumn('number', 'Day');
>       data.addColumn('number', 'Guardians of the Galaxy');
>       data.addColumn('number', 'The Avengers');
>       data.addColumn('number', 'Transformers: Age of Extinction');
>
>       data.addRows([
>         [1,  37.8, 80.8, 41.8],
>         [2,  30.9, 69.5, 32.4],
>         [3,  25.4,   57, 25.7],
>         [4,  11.7, 18.8, 10.5],
>         [5,  11.9, 17.6, 10.4],
>         [6,   8.8, 13.6,  7.7],
>         [7,   7.6, 12.3,  9.6],
>         [8,  12.3, 29.2, 10.6],
>         [9,  16.9, 42.9, 14.8],
>         [10, 12.8, 30.9, 11.6],
>         [11,  5.3,  7.9,  4.7],
>         [12,  6.6,  8.4,  5.2],
>         [13,  4.8,  6.3,  3.6],
>         [14,  4.2,  6.2,  3.4]
>       ]);
>
> Full example here --- 
> https://developers.google.com/chart/interactive/docs/gallery/linechart#top-x-charts
>
> On Wed, Jun 6, 2018 at 10:01 PM, 'Daniel LaLiberte' via Google 
> Visualization API <[email protected]> wrote:
>
>> I think the problem is that you are mixing table formats.  
>>
>> "rows":[
>> ["2018-05-06T11:15:00-0400",0.10,0.0,10,0.10,0.12],
>>   ...
>> That won't work because the structure is unexpected.  It would need to be 
>> more like:
>>
>> rows: [
>>           {c: [{v: 'Baltimore Ravens'},     {v: 'Date(2000, 8, 5)'}, {v: 
>> 'Date(2001, 1, 5)'}]},
>>
>> as documented here:
>>
>>
>> https://developers.google.com/chart/interactive/docs/datesandtimes#dates-and-times-using-the-date-string-representation
>>
>> Note that each row is an object with 'c' property.
>>
>>
>> On Wed, Jun 6, 2018 at 9:53 PM Daniel LaLiberte <[email protected]> 
>> wrote:
>>
>>> Leave the "new " off of the string and it should work better.
>>>
>>> On Wed, Jun 6, 2018 at 8:22 PM Wes Melton <[email protected]> 
>>> wrote:
>>>
>>>> Hi Daniel,
>>>>
>>>> Taking your suggestion, we've modified the output to send a string with 
>>>> a new Date constructor in to the Graph API, but now the error is saying: 
>>>>
>>>> "Error: Type mismatch. Value Date(2018,05,06,11,15) does not match type 
>>>> datetime in column index 0"
>>>>
>>>> Example array: 
>>>>
>>>> ["new Date(2018,05,06,11,15)", 0.1, 0.11, 0.09, 0.13, 0.13]
>>>>
>>>> We tried it without the 'new' verb (e.g. "Date(2018,05,06,11,15)" and 
>>>> that didn't work either. 
>>>>
>>>> Scratching our heads here a little bit.
>>>>
>>>>
>>>> On Wed, Jun 6, 2018 at 5:13 PM, 'Daniel LaLiberte' via Google 
>>>> Visualization API <[email protected]> wrote:
>>>>
>>>>> If you can pass a constructor to a place where JavaScript interprets 
>>>>> it, then JavaScript will interpret it.  The "Date(...)" form is parsed by 
>>>>> Google Charts, as if it were a constructor, even though it is a string.
>>>>>
>>>>> On Wed, Jun 6, 2018 at 5:12 PM Wes Melton <[email protected]> 
>>>>> wrote:
>>>>>
>>>>>> Data is coming from a PHP server.
>>>>>>
>>>>>> If a constructor is passed as a literal string in the output from the 
>>>>>> PHP server, you are saying the library will parse it?
>>>>>>
>>>>>> Get Outlook for iOS <https://aka.ms/o0ukef>
>>>>>> ------------------------------
>>>>>> *From:* 'Daniel LaLiberte' via Google Visualization API <
>>>>>> [email protected]>
>>>>>> *Sent:* Wednesday, June 6, 2018 4:59:39 PM
>>>>>> *To:* Google Visualization API
>>>>>> *Subject:* Re: [visualization-api] Possible bug with column type 
>>>>>> format validation? 
>>>>>>  
>>>>>> Your data looks like datetimes, but it is really strings.  We don't 
>>>>>> parse the strings, except for a string of the form "Date(yyyy, mm, dd, 
>>>>>> ...)", which is intended for use in JSON strings.  If you are not 
>>>>>> restricted by JSON rules, you can generate the JavaScript constructor 
>>>>>> instead, e.g. new Date(2018, 4, 6, 11, 15, 0).  Note that months start 
>>>>>> at 0.
>>>>>>
>>>>>> On Wed, Jun 6, 2018 at 4:50 PM Wes Melton <[email protected]> 
>>>>>> wrote:
>>>>>>
>>>>>>> Trying to dynamically build a line chart using the Google Charts 
>>>>>>> API.  
>>>>>>>
>>>>>>> This is the error being returned: 
>>>>>>>
>>>>>>> `Value 2018-05-06T11:15:00-0400 does not match type datetime in 
>>>>>>> column index`
>>>>>>>
>>>>>>> Without even looking at code, the error message is super confusing 
>>>>>>> as that is the ISO8601 format described in the documentation here: 
>>>>>>> https://developers.google.com/chart/interactive/docs/datesandtimes
>>>>>>>
>>>>>>> Here is the code building the chart: 
>>>>>>>
>>>>>>> var data = new google.visualization.DataTable();
>>>>>>>
>>>>>>>       for (var i = 0; i < chartData['cols'].length; i++) {
>>>>>>>         data.addColumn(chartData['cols'][i].type, 
>>>>>>> chartData['cols'][i].id);
>>>>>>>       }
>>>>>>>
>>>>>>>       for (var i = 0; i < chartData['rows'].length; i++) {
>>>>>>>         data.addRow(chartData['rows'][i]);
>>>>>>>       }
>>>>>>>
>>>>>>>       var view = new google.visualization.DataView(data);
>>>>>>>
>>>>>>>
>>>>>>> Here is a sample of chartData: 
>>>>>>>
>>>>>>> chartData = {
>>>>>>> "cols":[
>>>>>>> {"id":"created_dt","type":"datetime"},
>>>>>>> {"id":"Label 123","type":"number"},
>>>>>>> {"id":"Label 124","type":"number"},
>>>>>>> {"id":"Label 125","type":"number"},
>>>>>>> {"id":"Label 126","type":"number"},
>>>>>>> {"id":"Label 127","type":"number"}
>>>>>>> ],
>>>>>>> "rows":[
>>>>>>> ["2018-05-06T11:15:00-0400",0.10,0.0,10,0.10,0.12],
>>>>>>> ["2018-05-06T11:30:00-0400",0.40,0,0.14,0.01,0.17],
>>>>>>> ["2018-05-06T11:45:00-0400",0.33,0,0.38,0.08,0.20],
>>>>>>> ["2018-05-06T12:00:00-0400",0.33,0,0.56,0.10,0.23],
>>>>>>> ["2018-05-06T12:15:00-0400",0.23,0,0.64,0.07,0.33]
>>>>>>> ]
>>>>>>> }
>>>>>>>
>>>>>>> Any help on what I'm doing wrong here would be much appreciated. 
>>>>>>>
>>>>>>> -- 
>>>>>>> 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/a4eeb226-f294-4681-b664-261cba3c7640%40googlegroups.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/google-visualization-api/a4eeb226-f294-4681-b664-261cba3c7640%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
>>>>>>
>>>>>> -- 
>>>>>> 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/CAOtcSJOGVWt%3DBJc37mB8n2RbFV-k0gpb1MXRMvkFfB6%2Brw_uLw%40mail.gmail.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJOGVWt%3DBJc37mB8n2RbFV-k0gpb1MXRMvkFfB6%2Brw_uLw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>> -- 
>>>>>> 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/YTXPR0101MB1085926CA9244A32C957B014A5650%40YTXPR0101MB1085.CANPRD01.PROD.OUTLOOK.COM
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/google-visualization-api/YTXPR0101MB1085926CA9244A32C957B014A5650%40YTXPR0101MB1085.CANPRD01.PROD.OUTLOOK.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
>>>>>
>>>>> -- 
>>>>> 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/CAOtcSJOS-0UWuMRLiDVEPf%2BsM4pfKXUFdQRxES2A7n7wUgFjog%40mail.gmail.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJOS-0UWuMRLiDVEPf%2BsM4pfKXUFdQRxES2A7n7wUgFjog%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> -- 
>>>> 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/CAOyi8xfwHeixEV5uKatb%2BBu30pAd%3DVY8JyygPmNB3EiHb9PZ7A%40mail.gmail.com
>>>>  
>>>> <https://groups.google.com/d/msgid/google-visualization-api/CAOyi8xfwHeixEV5uKatb%2BBu30pAd%3DVY8JyygPmNB3EiHb9PZ7A%40mail.gmail.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/CAOtcSJNHG6cW%2Bok_vbTy1sMDTo72dx-igpN3DX%2BS2yKWecN9mw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJNHG6cW%2Bok_vbTy1sMDTo72dx-igpN3DX%2BS2yKWecN9mw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/16a706ee-e4d3-4dd2-bfd7-43206b8aa090%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to