示例#1
0
if ($result) {
    while ($ors = mysql_fetch_array($result)) {
        $indexCount++;
        //Create JavaScript code to add sub-array to data array
        //data is an array defined in JavaScript (see below)
        //We've added \t and \n to data so that if you View Source of the
        //output HTML, it will appear properly. It helps during debugging
        $jsVarString .= "\t\t data[" . $indexCount . "] = new Array(); \n";
        //Now create second query to get date-wise details for this factory
        $strQuery = "select * from Factory_Output where FactoryId=" . $ors['FactoryId'] . " order by DatePro Asc";
        $result2 = mysql_query($strQuery) or die(mysql_error());
        if ($result2) {
            while ($ors2 = mysql_fetch_array($result2)) {
                //Put this data into JavaScript as another nested array.
                //Finally the array would look like data[factoryIndex][i][dataLabel/name,dataValue]
                $jsVarString .= "\t\t" . "data[" . $indexCount . "].push(new Array('" . datePart("d", $ors2["DatePro"]) . "/" . datePart("m", $ors2['DatePro']) . "'," . $ors2['Quantity'] . ")); \n";
            }
            //free the resultset
            mysql_free_result($result2);
        }
        //Now create another query to get details for this factory
        $strQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" . $ors['FactoryId'];
        $result2 = mysql_query($strQuery) or die(mysql_error());
        $ors2 = mysql_fetch_array($result2);
        //Generate <set name='..' value='..' link='..' />
        //Note that we're setting link as updateChart(factoryIndex) - JS Function
        $strXML .= "<set name='" . $ors['FactoryName'] . "' value='" . $ors2['TotOutput'] . "' link='javaScript:updateChart(" . $indexCount . ")'/>";
    }
}
//Finally, close <graph> element
$strXML .= "</graph>";
示例#2
0
//to get that factory id, get information from database and then show
//a detailed chart.
//Request the factory Id from Querystring
$FactoryId = $_GET['FactoryId'];
//Generate the chart element string
$strXML = "<chart palette='2' caption='Factory " . $FactoryId . " Output ' subcaption='(In Units)' xAxisName='Date' showValues='1' labelStep='2' >";
// Connet to the DB
$link = connectToDB();
//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 label.
        $strXML .= "<set label='" . datePart("d", $ors['DatePro']) . "/" . datePart("m", $ors['DatePro']) . "' value='" . $ors['Quantity'] . "'/>";
    }
}
mysql_close($link);
//Close <chart> element
$strXML .= "</chart>";
//Create the chart - Column 2D Chart with data from strXML
echo renderChart("../../FusionCharts/Column2D.swf", "", $strXML, "FactoryDetailed", 600, 300, false, false);
?>
                        <BR/>
                        <a class="qua qua-button" style="margin-left: 360px" href="Default.php?animate=0"><span>Back to Summary</span></a>


                    </div>
                    <div class="clear"></div>
                    <p>&nbsp;</p>
//to get that factory id, get information from database and then show
//a detailed chart.
//Request the factory Id from Querystring
$FactoryId = $_GET['FactoryId'];
//Generate the graph element string
$strXML = "<graph caption='Factory " . $FactoryId . " Output ' subcaption='(In Units)' xAxisName='Date' formatNumberScale='0' decimalPrecision='0'>";
// Connet to the DB
$link = connectToDB();
//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 <graph> element
$strXML .= "</graph>";
//Create the chart - Column 2D Chart with data from strXML
echo renderChart("../../FusionCharts/FCF_Column2D.swf", "", $strXML, "FactoryDetailed", 600, 300);
?>
<BR>
<a href='Default.php'>Back to Summary</a>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>&laquo; Back to list of examples</a></h5>
</CENTER>
</BODY>