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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to