This is the my code i am using for column chart before the new release of
Google Api and it is working fine. Now my chart is not displaying. i have
checked the new release changes but i found noting relevant. the first
problem appears with the data type in array, float data type is not legal
and if i replaced it with some other data type then chart still not
displayed. if i change the float to string then error will appear that
string data type will not be used on X-axis. I have plotted time on X-axis
and Distance on Y-axis. If any one knows how to change the code according
to new release of Google Api please share your code or some information.
>
>
> // Connect to server and select database.
> $con=mysql_connect("$host", "$username")or die("cannot connect");
> mysql_select_db("$db_name")or die("cannot select DB");
>
> $data = mysql_query("select SUM(Distance) as Distance, CAST( Time AS date)
> as Time from gprs where DeviceId=25 and Time between '2013-08-08' and
> '2013-09-31' group by CAST(Time AS date) order by CAST( Time AS date)")
> or die(mysql_error());
>
> $table = array();
> $table['cols'] = array(
>
> array('label' => 'TIME', 'type' => 'string'),
> array('label' => 'Distance', 'type' => 'float')
> );
> $rows = array();while ($nt = mysql_fetch_assoc($data))
> {
>
> $temp = array();
> $temp[] = array('v' => (string)$nt['TIME']);
> $temp[] = array('v' =>(float) $nt['Distance']);
> $rows[]['c'] = $temp;
> }
> $table['rows'] = $rows;
> $jsonTable = json_encode($table);
> ?>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
> <title>
> Google Visualization API Sample
> </title>
> <script type="text/javascript" src="//www.google.com/jsapi"></script>
> <script type="text/javascript">
> google.load('visualization', '1', {packages: ['corechart']});
> </script>
> <script type="text/javascript">
> function drawVisualization() {
> // Create and populate the data table.
> var data = new google.visualization.DataTable(<?=$jsonTable?>);
>
> // Create and draw the visualization.
> new
> google.visualization.ColumnChart(document.getElementById('visualization')).
> draw(data);
> }
>
> google.setOnLoadCallback(drawVisualization);
> </script>
> </head>
> <body style="font-family: Arial;border: 0 none;">
> <div id="visualization" style="width: 600px; height: 300px;"></div>
> </body>
> </html>
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.