In this post i would like to explain about how to implementing graphs using fusion charts. And implemented using PHP. In my previous post explained about How to calculate statistics in daily, weekly , monthly and yearly using php. Get the information using that post and implement the graph using this code. Create a xml file with specific feilds and download the fusion charts from the site. By following example i will explain. We can get the values from database and create xml file as mentioned.
This picture denotes : A graph for number of registrations over the year ( by monthly ) divided men and women.

how to implement graphs using fusion charts and php | Anil Labs
1) Create a xml file :
In my previous post i have explained about how to calculate statistics in daily, weekly , monthly and yearly using php. By using this post we can get the categories.
Get the men registered numbers per month by using mysql quires.
$get_users_query = "select * from usertbl WHERE DATE_FORMAT( reg_date, '%Y.%M' ) = '".'2011'.$months[$d1]."' AND gender='male'";
$result = mysql_query($get_users_query);
$dataArrayDay_men[] = mysql_num_rows($result);
}
// Same for women
Prepare XML file
$strXMLYEAR = "<graph xaxisname='' yaxisname='No.Of Registrations' hovercapbg='F5589A' hovercapborder='F5589A' rotateNames='1' yAxisMaxValue='100' numdivlines='9' divLineColor='CCCCCC' divLineAlpha='80' decimalPrecision='0' showAlternateHGridColor='1' AlternateHGridAlpha='30' AlternateHGridColor='F5589A' caption='Registrations' subcaption='During a Year' >";
$strXMLYEAR .= "<categories font='Arial' fontSize='11' fontColor='000000'>";
for($i=(count($disp_months)-1);$i>=0;$i=$i-1){
$strXMLYEAR .= "<category name='".$disp_months[$i]."' hoverText='".$disp_months[$i]."'/>";
}
$strXMLYEAR .= "</categories><dataset seriesname='Men' color='FDC12E'>";
for($m1=(count($dataArrayDay_men)-1);$m1>=0;$m1=$m1-1){
$strXMLYEAR .= "<set value='".$dataArrayDay_men[$m1]."' />";
}
$strXMLYEAR .= "</dataset><dataset seriesname='Women' color='F5589A'>";
for($m1=(count($dataArrayDay_women)-1);$m1>=0;$m1=$m1-1){
$strXMLYEAR .= "<set value='".$dataArrayDay_women[$m1]."' />";
}
$strXMLYEAR .= "</dataset></graph>";
echo renderChart("Charts/FCF_MSColumn3D.swf", "", $strXMLYEAR, "productSales1235", 600, 300);
?>
Download fusion charts from from http://www.fusioncharts.com/
Hi,
Packt Publshing is looking for Technical Reviewers on “FusionCharts: Beginner’s Guide” If interested in reviewing it, contact [email protected]
Pingback : How to calculate statistics in daily, weekly , monthly and yearly using php - Anil Labs
That’s what i was looking for my admin panel. Thanks man you helped me complete my site 🙂