"; // Build category XML $strXML .= buildCategories ($resultCategories, "Date"); // Build datasets XML $strXML .= buildDatasets ( $resultData, "boiler1sf", "boiler2sf", "boiler3sf", "boiler4sf", "boiler5sf", "boiler6sf"); //Finally, close element $strXML .= ""; //Create the chart - Pie 3D Chart with data from strXML //echo renderChart("../../FusionCharts/MSLine.swf", "", $strXML, "FactorySum", 700, 400, false, false); echo renderChart("line", "", $strXML, 600, 300, false, false); // Free database resource mysql_free_result($resultCategories); mysql_free_result($resultData); mysql_close($link); /*********************************************************************************************** * Function to build XML for categories * @param $result Database resource * @param $labelField Field name as String that contains value for chart category labels * * @return categories XML node */ function buildCategories ( $result, $labelField ) { $strXML = ""; if ($result) { $strXML = ""; while($ors = mysql_fetch_array($result)) { $strXML .= ""; } $strXML .= ""; } return $strXML; } /*********************************************************************************************** * Function to build XML for datesets that would contain chart data * @param $result Database resource. The data should come ordered by a control break field which would require to identify datasets and set its value to dataset's series name * @param $valueField Field name as String that contains value for chart dataplots * @param $controlBreak Field name as String that contains value for chart dataplots * * @return Dataset XML node */ function buildDatasets ($result, $valueField, $controlBreak ) { $strXML = ""; if ($result) { $controlBreakValue =""; while( $ors = mysql_fetch_array($result) ) { if( $controlBreakValue != $ors[$controlBreak] ) { $controlBreakValue = $ors[$controlBreak]; $strXML .= ( $strXML =="" ? "" : "") . ( "" ) ; } $strXML .= ""; } $strXML .= ""; } return $strXML; } ?>