I wanted to know why my chart is not working. I have included the FusionCharts.php
and other necessary files in the project, and using the code below. The page comes up on my browser, but rather than displaying the chart it gives a No data to dispay
error. What could be the problem? Regards
<?php
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
include("Includes/FusionCharts.php");
include("Includes/DBConn.php");
?>
<HTML>
<HEAD>
<TITLE>
FusionCharts Free - Database Example
</TITLE>
<SCRIPT LANGUAGE="Javascript" SRC="js/FusionCharts.js"></SCRIPT>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> -Database and Drill-Down Example</h2>
<?php
//In this example, we show how to connect FusionCharts to a database.
//For the sake of ease, we've used an MySQL databases containing two
//tables.
// Connect to the DB
$link = connectToDB();
// Fetch all factory records
$strQuery = "select SUM(quantity) AS SUM, YEAR(datePro) AS YEAR FROM factory_output GROUP BY YEAR(datePro ) ";
$result = mysql_query($strQuery) or die(mysql_error());
//$strXML = "<graph caption='Factory Output report' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' showNames='1' formatNumberScale='0' numberSuffix=' Units' decimalPrecision='0'>";
$strXML = "<chart caption='Annual Revenue - last 3 years' numberPrefix='$'>";
//Iterate through each factory
while ($ors = mysql_fetch_array($result)){
//Generate <set name='..' value='..' />
$strXML .= "<set label ='" . $ors['YEAR'] . "' value='" . $ors['SUM'] . "' />";
}
//Finally, close <graph> element
$strXML .= "</chart>";
//Create the chart - Pie 3D Chart with data from $strXML
echo renderChart("charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 450);
mysql_free_result($result);
mysql_close($link);
?>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>« Back to list of examples</a></h5>
</CENTER>
</BODY>
</HTML>