Hello,
am new to this.
I have done all the settings as in this thread, with jason(alert) i am
getting the proper result but chart is not getting displayed, here is my
getData.php
<?php
$PageSecurity=0;
include('includes/session.inc');
if (!isset($RootPath)){
$RootPath = dirname(htmlspecialchars($_SERVER['PHP_SELF']));
if ($RootPath == '/' or $RootPath == "\\") {
$RootPath = '';
}
}
$SQL = "SELECT stockmaster.stockid,
stockmaster.description,
stockmaster.longdescription,
stockmaster.mbflag,
stockmaster.discontinued,
SUM(locstock.quantity) AS qoh,
stockmaster.units,
stockmaster.decimalplaces
FROM stockmaster
LEFT JOIN stockcategory
ON stockmaster.categoryid=stockcategory.categoryid,
locstock
WHERE stockmaster.stockid=locstock.stockid
GROUP BY stockmaster.stockid,
stockmaster.description,
stockmaster.longdescription,
stockmaster.units,
stockmaster.mbflag,
stockmaster.discontinued,
stockmaster.decimalplaces
ORDER BY stockmaster.discontinued, stockmaster.stockid";
$searchresult = DB_query($SQL, $db);
$table=array();
$table['cols']=array(
array('label'=>'CODE', type=>'string'),
array('label'=> 'Description', type=>'string'),
array('label'=>'Units', type=>'string'),
array('label'=>'Quantity', type=>'number')
);
$rows=array();
//echo "<table width='100%' celpadding='2' class='selection'>";
//echo "<tbody><tr><th> Code </th><th>Description</th><th>Total QTY on
Hand</th><th>Units</th><th>Flag</th></tr> ";
//$k=0;
while ($row = DB_fetch_array($searchresult))
{
//$qoh = locale_number_format($row['qoh'], $myrow['decimalplaces']);
//$stockid = $row['stockid'];
//$desc = $row['description'];
//$units = $row['units'];
//$mbflag = $row['mbflag'];
$temp=array();
$temp[]=array('v' => $row['stockid']);
$temp[]=array('v' => $row['description']);
$temp[]=array('v' => $row['qoh']);
$temp[]=array('v' => $row['units']);
$rows[]=array('c' => $temp);
}
$table['rows']=$rows;
$jsonTable = json_encode($table);
print $jsonTable;
?>
and this is my display page
echo '<script type="text/javascript" src =
"'.$RootPath.'/javascripts/MiscFunctions.js"></script>';
echo '<script type="text/javascript"
src="https://www.google.com/jsapi"></script>';
echo '<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
type="text/javascript"></script>';
echo ' <script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "getData.php",
dataType:"json",
async: false
}).responseText;
alert(jsonData);
var data = new google.visualization.DataTable(jsonData);
var view = new google.visualization.DataView(data);
view.setColumns([0, 3]);
var chart = new
google.visualization.PieChart(document.getElementById("chart_div"));
chart.draw(view, {width:400, height:240});
}
</script>';
echo '<style media="screen">
.noPrint{ display: block; }
.yesPrint{ display: block !important; }
</style>
<style media="print">
.noPrint{ display: none; }
.yesPrint{ display: block !important; }
</style>';
echo '</head>';
?>
<?php
<div id="chart_div"></div>
?>
Please help me why chart is not getting displayed
--
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.