我创建了两个php页面。第一个是主要的融合图,它绘制了各个工厂的总产量的饼图。我还包括了一个使图表可点击的方法。单击时,它意味着显示构成图表部分的细分图分析。但是向下钻取图表拒绝绘制任何图表,而是在屏幕上显示空图表字符串。我已经为您的分析放置了代码。
<?php
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
//functions to help us easily embed the charts and connect to a database.
include("/Includes/FusionCharts.php");
include("/Includes/DBConn.php");
//a file having a list of colors to be applied to each column (using getFCColor() function)
include("/Includes/FC_Colors.php");
?>
<HTML>
<HEAD>
<TITLE> FusionCharts Free - Database and Drill-Down Example </TITLE>
<SCRIPT LANGUAGE="Javascript" SRC="../../FusionCharts/FusionCharts.js"> </SCRIPT>
</HEAD>
<BODY>
<?php
//This page is invoked from Default.php. When the user clicks on a pie
//slice in Default.php, the factory Id is passed to this page. We need
//to get that factory id, get information from database and then show
//a detailed chart.
//First, get the factory Id
//Request the factory Id from Querystring
$factoryId = $_GET['factoryId'];
//Connect to database
$link = connectToDB();
//$strXML will be used to store the entire XML document generated
//Generate the chart element string
$strXML = "<chart caption='Factory Output' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' showNames='1' formatNumberScale='0' numberSuffix=' Units' decimalPrecision='0'>";
//Now, we get the data for that factory
$strQuery = "select * from factory_output where factoryId=" . $factoryId;
$result = mysql_query($strQuery) or die(mysql_error());
//Iterate through each factory
if ($result) {
while($ors = mysql_fetch_array($result)) {
//Here, we convert date into a more readable form for set name.
$strXML .="<set name='" . datePart("d",$ors['datePro']) . "/" . datePart("m",$ors['datePro']) . "' value='" . $ors['quantity'] . "' color='" . getFCColor() . "'/>";
}
}
mysql_close($link);
//Close <chart> element
$strXML .="</chart>";
//Create the chart - Column 2D Chart with data from $strXML
echo renderChart("charts/FCF_Column3D.swf", "", $strXML, "FactoryDetailed", 600, 300);
?>
</CENTER>
</BODY>
</HTML>