I searched a lot and finally was able to run my google chart code. Here is my code using both a data view and a data table.
// Here is my code for chartDraw.php
<html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function drawChart(){ var jsonData = $.ajax({ url:"getdata.php", dataType:"json", async:false }).responseText; </script> </head> <body> <div id="chart_div"></div> </body> </html>
//getdata.php: contains connections and request
<?php mysql_connect('localhost','user','password'); mysql_select_db('dbname'); $sqlquery1="select userid,group_name,req_nodes,actualPE from jobs where userid='zhang' limit 200"; $sqlresult1=mysql_query($sqlquery1); $table=array(); $table['cols']=array( array('label'=> 'User ID', type=>'string'), array('label'=>'Group Name', type=>'string'), array('label'=>'Requested Nodes', type=>'number'), array('label'=>'Actual PE', type=>'number') ); $rows=array(); while($r=mysql_fetch_assoc($sqlresult1)){ $temp=array(); $temp[]=array('v' => $r['userid']); $temp[]=array('v' => $r['group_name']); $temp[]=array('v' =>(int) $r['req_nodes']); $temp[]=array('v' =>(float) $r['actualPE']); $rows[]=array('c' => $temp); } $table['rows']=$rows; $jsonTable = json_encode($table);
What is the difference between a DataView class and a DataTable constructor? If I do not use a DataView , it does not print.
source share