As I mentioned in one of my previous responses, DataTable.addRows does not
support this format. You need to remove the code that creates the DataTable
via the addRows method, since you are currently redefining the dataTable
variable, making it not pick up the actual working code.

On Wed Feb 04 2015 at 12:29:23 PM Raphael Saldanha <[email protected]>
wrote:

> Thanks Sergey and Daniel!
>
> I will deal with the month offset next. Changed the quotes on PHP, but no
> plot yet. The console says: Error: Type mismatch. Value Date(2013, 12, 2)
> does not match type date in column index 0
>
> On Wed, Feb 4, 2015 at 3:21 PM, 'Daniel LaLiberte' via Google
> Visualization API <[email protected]> wrote:
>
>> One more issue is bound to come up.  Your date month numbers will appear
>> to be off by one, but month numbers are based on 0 (in JavaScript and most
>> other languages), so you will actually want e.g. "Date(2013, 11, 2)", for
>> December 2, 2013.
>>
>> On Wed, Feb 4, 2015 at 12:14 PM, 'Sergey Grabkovsky' via Google
>> Visualization API <[email protected]> wrote:
>>
>>> Your PHP needs to surround the Dates with quotes. Hence it being a
>>> *string* representation. So it needs to output data that looks like:
>>> [[ "Date(2013, 12, 2)", 254 ],[ "Date(2013, 12, 3)", 202 ] ...
>>>
>>> On Wed Feb 04 2015 at 12:07:36 PM Raphael Saldanha <[email protected]>
>>> wrote:
>>>
>>>> Really thanks! I'm trying to follow your steps but I'm failing at some
>>>> point... please take a look:
>>>>
>>>> PHP JSON: http://ebib.com.br/plotsus/data2/dados.php
>>>> HTML: http://ebib.com.br/plotsus/data2/
>>>>
>>>> On Wed, Feb 4, 2015 at 2:42 PM, 'Sergey Grabkovsky' via Google
>>>> Visualization API <[email protected]> wrote:
>>>>
>>>>> It's generally considered dangerous to use eval to parse JSON. Here's
>>>>> a relevant excerpt from "JavaScript The Good Parts":
>>>>> https://www.safaribooksonline.com/library/view/javascript-the-good/9780596517748/apes02.html
>>>>>
>>>>> The more correct way would be to encode your Dates into the Date
>>>>> String representation, as I outlined in my previous post, and use either
>>>>> the DataTable object literal notation or arrayToDataTable to get the data
>>>>> into a DataTable. Personally, I prefer (and recommend) to use the
>>>>> arrayToDataTable function.
>>>>>
>>>>> Assuming that you change your PHP to return Dates in the "correct"
>>>>> way, it would change your code to the following:
>>>>>        var dataArray = [
>>>>>          [{ type: 'date', id: 'Date' }, { type: 'number', id:
>>>>> 'Won/Loss' }]
>>>>>        ]; // Set up the headers
>>>>>        // Add the parsed JSON data to the data array.
>>>>>        dataArray.push.apply(dataArray, $.parseJSON(jsonData));  //
>>>>> note that this will fail for large arrays, and you may need to use a for
>>>>> loop instead
>>>>>        var dataTable = google.visualization.arrayToDataTable(dataArray
>>>>> );
>>>>>
>>>>> On Wed Feb 04 2015 at 11:35:42 AM Raphael Saldanha <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Just got! Using dataTable.addRows(eval(jsonData)); works. But which
>>>>>> is the "most correct" method?
>>>>>>
>>>>>> On Wed, Feb 4, 2015 at 2:32 PM, 'Sergey Grabkovsky' via Google
>>>>>> Visualization API <[email protected]> wrote:
>>>>>>
>>>>>>> Your issue now is two-fold. The data stored in jsonData is a string,
>>>>>>> not an array of arrays, so you will need to parse it. You can use
>>>>>>> $.parseJSON(jsonData) to do that for you. However, the second issue is 
>>>>>>> that
>>>>>>> that won't work, since "new Date" isn't valid JSON. You will need to use
>>>>>>> the Date String representation (
>>>>>>> https://developers.google.com/chart/interactive/docs/datesandtimes#datestring)
>>>>>>> in order to make that work. Please note that the Date String 
>>>>>>> representation
>>>>>>> does not work with addRows, so you will either have to use the DataTable
>>>>>>> object literal notation or arrayToDataTable instead.
>>>>>>>
>>>>>>> On Wed Feb 04 2015 at 11:15:47 AM Raphael Saldanha <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hi! Really thanks for your attention. I had changed the line, but
>>>>>>>> still no plot... You can check here:
>>>>>>>> http://ebib.com.br/plotsus/data/index.html
>>>>>>>>
>>>>>>>> On Wed, Feb 4, 2015 at 1:10 PM, 'Sergey Grabkovsky' via Google
>>>>>>>> Visualization API <[email protected]>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi Raphael,
>>>>>>>>>
>>>>>>>>> You have an extra set of brackets in your dataTable.addRows call.
>>>>>>>>> You JSON data already returns an array of arrays, and putting brackets
>>>>>>>>> around it causes it to be an array of arrays of arrays, which is not 
>>>>>>>>> the
>>>>>>>>> format that addRows takes. Simply changing your line to "dataTable
>>>>>>>>> .addRows(jsonData)" should fix your issues.
>>>>>>>>>
>>>>>>>>> On Wed Feb 04 2015 at 7:01:33 AM Raphael Saldanha <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Hi everyone,
>>>>>>>>>>
>>>>>>>>>> I have a php file that returns an array and I'm trying to use
>>>>>>>>>> those data to create a Google Chart Calendar visualization.
>>>>>>>>>>
>>>>>>>>>> The php file is here: http://ebib.com.br/plotsus/data/dados.php
>>>>>>>>>>
>>>>>>>>>> And below is my html code. If I just paste the results from PHP
>>>>>>>>>> inside
>>>>>>>>>> dataTable.addRows([ ... ]);
>>>>>>>>>>
>>>>>>>>>> everything goes ok, but not happens when I use the code below.
>>>>>>>>>> Please help!
>>>>>>>>>>
>>>>>>>>>> <html>
>>>>>>>>>>   <head>
>>>>>>>>>>     <script language="javascript" type="text/javascript"
>>>>>>>>>>         src="
>>>>>>>>>> http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js";>
>>>>>>>>>>     </script>
>>>>>>>>>>     <script type="text/javascript" src="
>>>>>>>>>> https://www.google.com/jsapi";></script>
>>>>>>>>>>     <script type="text/javascript">
>>>>>>>>>>       google.load("visualization", "1.1", {packages:["calendar"
>>>>>>>>>> ]});
>>>>>>>>>>       google.setOnLoadCallback(drawChart);
>>>>>>>>>>
>>>>>>>>>>    function drawChart() {
>>>>>>>>>>             var jsonData = $.ajax({
>>>>>>>>>>                 url: "dados.php",
>>>>>>>>>>                 dataType: "json",
>>>>>>>>>>                 async: false
>>>>>>>>>>             }).responseText;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>        var dataTable = new google.visualization.DataTable();
>>>>>>>>>>        dataTable.addColumn({ type: 'date', id: 'Date' });
>>>>>>>>>>        dataTable.addColumn({ type: 'number', id: 'Won/Loss' });
>>>>>>>>>>
>>>>>>>>>>        dataTable.addRows([ jsonData ]);
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>        var chart = new google.visualization.Calendar(document.
>>>>>>>>>> getElementById('calendar_basic'));
>>>>>>>>>>
>>>>>>>>>>        var options = {
>>>>>>>>>>          title: "Red Sox Attendance",
>>>>>>>>>>          height: 350,
>>>>>>>>>>        };
>>>>>>>>>>
>>>>>>>>>>        chart.draw(dataTable, options);
>>>>>>>>>>    }
>>>>>>>>>>     </script>
>>>>>>>>>>   </head>
>>>>>>>>>>   <body>
>>>>>>>>>>     <div id="calendar_basic" style="width: 1000px; height: 350px;
>>>>>>>>>> "></div>
>>>>>>>>>>   </body>
>>>>>>>>>> </html>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  --
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>  --
>>>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>>>> the Google Groups "Google Visualization API" group.
>>>>>>>>> To unsubscribe from this topic, visit
>>>>>>>>> https://groups.google.com/d/topic/google-visualization-api/goOPKt0-hYw/unsubscribe
>>>>>>>>> .
>>>>>>>>> To unsubscribe from this group and all its topics, 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.
>>>>>>>>>
>>>>>>>>  --
>>>>>>>> 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.
>>>>>>>>
>>>>>>>  --
>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>> the Google Groups "Google Visualization API" group.
>>>>>>> To unsubscribe from this topic, visit
>>>>>>> https://groups.google.com/d/topic/google-visualization-api/goOPKt0-hYw/unsubscribe
>>>>>>> .
>>>>>>> To unsubscribe from this group and all its topics, 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.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>> 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.
>>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "Google Visualization API" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/d/topic/google-visualization-api/goOPKt0-hYw/unsubscribe
>>>>> .
>>>>> To unsubscribe from this group and all its topics, 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.
>>>>>
>>>>
>>>>  --
>>>> 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.
>>>>
>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
>>  - 978-394-1058
>> [email protected] <[email protected]>   5CC, Cambridge MA
>> [email protected] <[email protected]> 9 Juniper Ridge
>> Road, Acton MA
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Google Visualization API" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/google-visualization-api/goOPKt0-hYw/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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.
>>
>
>  --
> 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.
>

-- 
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