Hi all,
I struck with displaying google charts. Can you please help me with that.
Here is the code for Image bar:
<?php
include('db_connect.php');
$data[] = array('wonum','elapsedday');
$sql = "SELECT wonum, DATEDIFF(dt_on,dt_off) AS elapsedday from elapsed;";
$query = mysql_query($sql);
while($result = mysql_fetch_array($query))
{
$data[] = array($result['wonum'],(int)$result['elapsedday']);
}
// $data = array($data);
echo json_encode($data);
mysql_close($db);
?>
Here the code for graph.php which is used to run to display the chart:
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="
https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//
ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(image_chart);
function image_chart() {
var jsonData = $.ajax({
url: "imagebar.php",
dataType: "json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
// alert(jsonData);return false;
var data = new google.visualization.DataView(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new
google.visualization.PieChart(document.getElementById('image_div'));
chart.draw(data, {width: 400, height: 240});
}
</script>
</head>
<body>
<div style="font: 21px arial; padding: 10px 0 0 100px;">Image bar
Chart</div>
<div id="image_div"></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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/36de54eb-d10e-4451-9cf0-3321babd2581%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.