If your new data comes in the same format as your original data, this might 
be the easiest way to add the new data:

var newData = JSON.parse(newJSON);
var dataObj = JSON.parse(data.toJSON);

dataObj.rows.concat(newData.rows);

data = new google.visualization.DataTable(dataObj);

If that doesn't work, you can do this:

var newData = new google.visualization.DataTable(newJSON);
var row;
for (var i = 0; i < newData.getNumberOfRows(); i++) {
    row = [];
    for (var j = 0; j < newData.getNumberOfColumns(); j++) {
        row.push({v: newData.getValue(i, j), 
f: newData.getFormattedValue(i, j)});
    }
    data.addRow(row);
}

On Tuesday, August 27, 2013 2:41:56 PM UTC-4, CGO wrote:
>
> Hi,
>
> I am stuck with what is probably a simple thing. Overall I am trying to 
> work on Dashboard, which uses a ChartRangeFilter. I am loading the 
> dashboard with limited data initially (Indexed by dates) which is populated 
> from a PHP script returning JSON (loading it via 
> google.visualization.DataTable()) and it all works perfectly. Afterwards 
> when the user selects older dates in the RangeFilter I want to expand the 
> data via a listener calling an ajax procedure to bring JSON data for 
> previous dates.
>
> I have been trying to use addRows() unsuccessfully because there is no 
> Date() object in JSON. I have also tried passing the date as a string as in 
> this two examples:
>
> [ ["Mon Jun 17 2013 19:01:00 GMT+0100 (BST)", 49.993] ]
> [ ["Date(2013,5,17,19,01,00)", 49.993] ] 
>
> Is there another way I can add rows to an already existing datatable? Or 
> another way I could possibly achieve this?
>
> Cheers
>
> CGO
>
>
>
>

-- 
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/groups/opt_out.

Reply via email to