If the data for the two charts is independent, then you probably want two separate data sources (lets call them sourceA.php and sourceB.php). You can then arrange the javascript in different ways: either grouping the two tables into a single draw call or having two separate draw calls. If the tables share a common set of attributes (like the same base set of options) or need to communicate with one another, then they should be in one draw call. If they are independent of one another, then they can go into two draw calls. Pseudocoding it out, these would look like this:
// 1 draw call google.load('visualization', '1', {packages: ['controls']}); google.setOnLoadCallback(drawChart); function drawChart () { [AJAX call to sourceA.php to get data for chartA] [create and draw chartA] [AJAX call to sourceB.php to get data for chartB] [create and draw chartB] } // two separate draw calls google.load('visualization', '1', {packages: ['controls']}); google.setOnLoadCallback(init); function init () { drawChartA(); drawChartB(); } function drawChartA () { [AJAX call to sourceA.php to get data for chartA] [create and draw chartA] } function drawChartB () { [AJAX call to sourceB.php to get data for chartB] [create and draw chartB] } If, however, the data for the two charts is related (different columns pulled from the same table, as an example), then it might make sense to have one data pull that gets all the data for both charts at once. You can then separate out the data using DataViews. On Thursday, April 11, 2013 2:23:36 AM UTC-4, kolo ken wrote: > > Thank asgallant, > Now i want try to have two tableS in my database, lets say table A and > table B, so what is the writing format in php and html... > > *Goo.php* > //retrieve data from Table A > <?php > $con=mysql_connect("localhost","root","") or die("problemas al conectarse > al server!!!!"); > mysql_select_db("epat", $con); > $sth = mysql_query("SELECT * FROM A"); > $rows = array(); > $flag = true; > $table = array(); > $table['cols'] = array( > array('label' => 'U', 'type' => 'string'), > ); > $rows = array(); > while($r = mysql_fetch_assoc($sth)) { > $temp = array(); > $temp[] = array('v' => (string) $r['U']); > $rows[] = array('c' => $temp); > } > $table['rows'] = $rows; > $jsonTable = json_encode($table); > echo $jsonTable; > ?> > > //retrieve data from Table B > <?php > $con=mysql_connect("localhost","root","") or die("problemas al conectarse > al server!!!!"); > mysql_select_db("epat", $con); > $sth = mysql_query("SELECT * FROM A"); > $rows = array(); > $flag = true; > $table = array(); > $table['cols'] = array( > array('label' => 'T', 'type' => 'string'), > ); > $rows = array(); > while($r = mysql_fetch_assoc($sth)) { > $temp = array(); > $temp[] = array('v' => (string) $r['T']); > $rows[] = array('c' => $temp); > } > $table['rows'] = $rows; > $jsonTable = json_encode($table); > echo $jsonTable; > ?> > > *HTML* > Chart for tableA > <script type="text/javascript"> > google.load('visualization', '1', {packages: ['controls']}); > google.setOnLoadCallback(drawChart); > > function drawChart1() { > var jsonData =$.ajax({ > url: "Goo.php", > dataType:"json", > async: false > }).responseText; > > var data = new google.visualization.DataTable(jsonData); > ......... > </script> > > Chart for TableB > <script type="text/javascript"> > google.load('visualization', '1', {packages: ['controls']}); > google.setOnLoadCallback(drawChart); > > function drawChart2() { > var jsonData =$.ajax({ > url: "Goo.php", > dataType:"json", > async: false > }).responseText; > > var data = new google.visualization.DataTable(jsonData); > ......... > </script> > > Please correct me If I'm wrong? > -- 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 google-visualization-api+unsubscr...@googlegroups.com. To post to this group, send email to google-visualization-api@googlegroups.com. Visit this group at http://groups.google.com/group/google-visualization-api?hl=en. For more options, visit https://groups.google.com/groups/opt_out.