Hello All,
I need help in Google Bar Charts API using with mysql/PHP,
If you look at data.setValue in this javascript code, you will notice that I have passed values using php functions with different parameters; actually these parameters are instruction to mysql query to grab data;
for example function1($parameter){
return mysql num rows where parameter=parameter; }
If I was going to display all the rows in html table, it only requires a while loop to grab data from the db table,
In Google Maps API if I do it manually, it will take a lot of time, my question is;is there any way to create google api dataTable using php loops?
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Col1');
data.addColumn('number', 'Col2');
data.addColumn('number', 'Col3');
data.addColumn('number', 'Col4');
data.addRows(5);
data.setValue(0, 0, 'Row1');
data.setValue(0, 1, <?=function1(parameter1);?>);
data.setValue(0, 2, <?=function2(parameter1);?>);
data.setValue(0, 3, <?=function3(parameter1);?>);
data.setValue(1, 0, 'Row2');
data.setValue(1, 1, <?=function1(parameter2);?>);
data.setValue(1, 2, <?=function2(parameter2);?>);
data.setValue(1, 3, <?=function3(parameter2);?>);
data.setValue(2, 0, 'Row3');
data.setValue(2, 1, <?=function1(parameter3);?>);
data.setValue(2, 2, <?=function2(parameter3);?>);
data.setValue(2, 3, <?=function3(parameter3);?>);
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, {
isStacked:true,
width: 900, height: 1100, title: 'Drivers Performance',
vAxis: {title: 'Drivers', titleTextStyle: {color: 'red'}}
});
}
</script>