I posted a code snippet I use for transforming database output from PHP into JSON that the charts can understand:
https://groups.google.com/d/msg/google-visualization-api/Gy18YdVSSfQ/tKdtzSfqKlcJ
You can either echo that output into the constructor of the DataTable - ie:
var data = new google.visualization.DataTable(<?php echo $json_encoded_data; ?>);
or you can use that code as a data source and make AJAX calls to it, putting the returned json into the DataTable constructor, ie:
google.load('visualization', '1.0', {'packages': ['corechart']});
google.setOnLoadCallback(init);
function init () {
// get parameters to submit to data source
var params;
// get data w/ AJAX call
$.ajax({
url: '/path/to/data_query.php',
data: params,
type: json,
success: function (json) {
var data = new google.visualization.DataTable(json);
var chart = new google.visualization.ChartType(document.getElementById('chart_div'));
chart.draw(data, {/*options*/});
}
});
}