Skip to content Skip to sidebar Skip to footer

Draw Google Charts With JSON

How can I retrieve and use a dataset for google charts if it was a separate JSON file?? I tried jQuery getJSON but couldn't get it worked.. Google Viz should use the JSON to draw a

Solution 1:

new google.visualization.DataTable(json) works.

Look the output of dataTable.toJSON() for the correct structure to use.

So, if you have a getjson.php script on your server that returns correctly formatted json, you could do that:

$.getJSON('/getjson.php', function(json) {
    var dataTable = new google.visualization.DataTable(json);
});

Post a Comment for "Draw Google Charts With JSON"