How do I populate the Google Chart API with my own Server side data i.e. in PHPMySQL.
Currently I have the following data:
function drawChart()
{
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'City');
data.addColumn('number', 'Number of Crimes');
data.addRows([
['Cardiff', 300],
['London', 900],
['Manchester', 500],
['Dublin', 400],
['Liverpool', 600]
]);
// Set Chart Options
var options = {
'legend': 'left',
'title': 'Crimes (per day)',
'is3D': 'True',
'width':400,
'height':300
};
// Instantiate and Draw Chart.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
But how do I feed it the data from a table in my mySQL database?
Before the JavaScript-Code of the Charts API you have to get your data out of your database:
Now replace in your JS-code:
With: