Phanik18 Report post Posted September 14, 2011 Hi , i have two php pages which render two charts. i want to render these two charts in single page. Please help me on this Test1.php <?php include("Includes/FusionCharts.php"); include("Includes/DBConn.php"); ?> <HTML> <HEAD> <TITLE>NC Closure Status</TITLE> <script LANGUAGE="Javascript" SRC="FusionCharts.js"></SCRIPT> </HEAD> <BODY> <CENTER> <?php $link = connectToDB(); $phani=21; $strXML = "<graph xaxisname='Project' yaxisname='Count' caption='NC Closure Status' lineThickness='1' animation='1' showNames='1' alpha='100' showLimits='1' rotateNames='1' numDivLines='3' decimalPrecision='0' showValues='1' placeValuesInside='1' use3DLighting='1'>"; //Start XML Code $strquery = " SELECT distinct nc_information.Project_Audit_Id,project_details.name FROM audit_details ,project_audit , project_details , nc_information where project_audit.Audit_Id=audit_details.id and project_details.Id=project_audit.project_id and audit_details.id=$phani and nc_information.Project_Audit_Id=project_audit.id group by nc_information.Project_Audit_Id,nc_state_id "; //String Query database $query2 = mysql_query($strquery); //call string query $strCategories = "<categories>"; //create categories while ($cat = mysql_fetch_array($query2)) { $strCategories .= "<category name='" . $cat[1] . "' />"; //display categories }; $strCategories .= "</categories>"; /*$K10 = "<dataset seriesName='Closed' color='008040'>"; $query2 = mysql_query($strquery); while ($cat = mysql_fetch_array($query2)) //phani1 { $strqueryclose = "SELECT count(title) as closed FROM nc_information where Project_Audit_Id='$cat[0]' and NC_State_Id=6"; $query4 = mysql_query($strqueryclose); //call string query while ($MK10 = mysql_fetch_array($query4)) { $K10 .= "<set value='" . $MK10[0] . "' />"; //display value of dataset } } $K10 .= "</dataset>"; echo $K10; exit; */ //open start $K5 = "<dataset seriesName='Open'>"; //create dataset $query2 = mysql_query($strquery); while ($cat = mysql_fetch_array($query2)) //phani1 { $strqueryopen = "SELECT replace(count(title),0,'') as open FROM nc_information where Project_Audit_Id='$cat[0]' and NC_State_Id in (1,2,3,8,9,10)"; $query3 = mysql_query($strqueryopen); //call string query while ($MK5 = mysql_fetch_array($query3)) { $K5 .= "<set value='" . $MK5[0] . "' />"; //display value of dataset } } $K5 .= "</dataset>"; //open end //closed start $K10 = "<dataset seriesName='AP Submitted'>"; //create dataset $query2 = mysql_query($strquery); while ($cat = mysql_fetch_array($query2)) //phani1 { $strqueryclose = "SELECT replace(count(title),0,'') as closed FROM nc_information where Project_Audit_Id='$cat[0]' and NC_State_Id in (4,11)"; $query4 = mysql_query($strqueryclose); //call string query while ($MK10 = mysql_fetch_array($query4)) { $K10 .= "<set value='" . $MK10[0] . "' />"; //display value of dataset } } $K10 .= "</dataset>"; //closed end //inprogress start $K20 = "<dataset seriesName='Ready For Verification' color='3C98FF'>"; //create dataset $query2 = mysql_query($strquery); while ($cat = mysql_fetch_array($query2)) //phani1 { $strqueryprogress = "SELECT replace(count(title),0,'') as closed FROM nc_information where Project_Audit_Id='$cat[0]' and NC_State_Id in (5,12)"; $query5 = mysql_query($strqueryprogress); //call string query while ($MK20 = mysql_fetch_array($query5)) { $K20 .= "<set value='" . $MK20[0] . "' />"; //display value of dataset } } $K20 .= "</dataset>"; //inprogress end $K30 = "<dataset seriesName='Closed' color='51EF49'>"; //create dataset $query2 = mysql_query($strquery); while ($cat = mysql_fetch_array($query2)) //phani1 { $strqueryprogress = "SELECT count(title) as closed FROM nc_information where Project_Audit_Id='$cat[0]' and NC_State_Id in (6,7)"; $query6 = mysql_query($strqueryprogress); //call string query while ($MK30 = mysql_fetch_array($query6)) { $K30 .= "<set value='" . $MK30[0] . "' />"; //display value of dataset } } $K30 .= "</dataset>"; $strXML .= $strCategories . $K5 . $K10 . $K20 .$K30 . "</graph>"; //end of XML //echo renderChart("Charts/StackedColumn3D.swf", "", $strXML, "productSales", 700, 500, false, false); ?> Test2.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"); ?> <HTML> <HEAD> <TITLE>FusionCharts - Database Example</TITLE> <script LANGUAGE="Javascript" SRC="FusionCharts.js"></SCRIPT> </HEAD> <BODY> <CENTER> <?php //In this example, we show how to connect FusionCharts to a database. //For the sake of ease, we've used a MySQL database containing two //tables. //Connect to the DB $link = connectToDB(); //$strXML will be used to store the entire XML document generated //Generate the chart element $strXML = "<graph caption='Factory Output report' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' Units'>"; //Fetch all factory records $strQuery = "select * from project_audit where Id in (207,71,50)"; $result = mysql_query($strQuery) or die(mysql_error()); //Iterate through each factory if ($result) { while($ors = mysql_fetch_array($result)) { //Now create a second query to get details for this factory $strQuery = "select count(Title) as TotOutput from nc_information where Project_Audit_Id=" . $ors['Id']; $result2 = mysql_query($strQuery) or die(mysql_error()); $ors2 = mysql_fetch_array($result2); //Generate <set label='..' value='..'/> $strXML .= "<set label='" . $ors['Project_Id'] . "' value='" . $ors2['TotOutput'] . "' />"; //free the resultset mysql_free_result($result2); } } mysql_close($link); //Finally, close <chart> element $strXML .= "</graph>"; $strXML1=$strXML; //Create the chart - Pie 3D Chart with data from $strXML echo renderChart("charts/Pie3D.swf", "", $strXML1, "FactorySum", 600, 300, false, true); ?> </BODY> </HTML> I want to render these two charts in single file ( Ex : test3.php ) Share this post Link to post Share on other sites
Guest Angshu Report post Posted September 14, 2011 Hi, Welcome to FusionCharts Forum! Creating multiple charts in a page is as easy as creating a single chart. You can create as many charts as you wish. All you need to take care is that you should set unique chart id to each chart. For more details, please visit the link: http://www.fusioncha...e.html#multiple Hope this helps. Share this post Link to post Share on other sites
Phanik18 Report post Posted September 15, 2011 Hi Angshu , Thank you for the reply. echo renderChart("../../FusionCharts/Column3D.swf", "Data/Data.xml", "", "chart1", 600, 300, false, true); //Now, create a Column 2D Chart echo renderChart("../../FusionCharts/Column2D.swf", "Data/Data.xml", "", "chart2", 600, 300, false, true); //Now, create a Line 2D Chart echo renderChart("../../FusionCharts/Line.swf", "Data/Data.xml", "", "chart3", 600, 300, false, true); I am not able to undertand "Data/Data.xml" , because here i dn't have any direct XML file , XML is getting rendered dynamically in php pages ( test1.php , test2.php). in this case how can i pass the XML to render chart in differet page. Thank you. Hi, Welcome to FusionCharts Forum! Creating multiple charts in a page is as easy as creating a single chart. You can create as many charts as you wish. All you need to take care is that you should set unique chart id to each chart. For more details, please visit the link: http://www.fusioncha...e.html#multiple Hope this helps. Share this post Link to post Share on other sites
Swarnam Report post Posted September 15, 2011 Hi, Thank you for the mail. The XML data document is stored in a PHP variable "strXML" using string concatenation . Create the chart and set the dataStr parameter as strXML. We leave dataUrl parameter blank. echo renderChart("../../FusionCharts/Column3D.swf", "", $strXML , "chart1", 600, 300, false, true); //Now, create a Column 2D Chart echo renderChart("../../FusionCharts/Column2D.swf", "", $strXML , "chart2", 600, 300, false, true); //Now, create a Line 2D Chart echo renderChart("../../FusionCharts/Line.swf", "",$strXML , "chart3", 600, 300, false, true); I hope this helps. Hi Angshu , Thank you for the reply. echo renderChart("../../FusionCharts/Column3D.swf", "Data/Data.xml", "", "chart1", 600, 300, false, true); //Now, create a Column 2D Chart echo renderChart("../../FusionCharts/Column2D.swf", "Data/Data.xml", "", "chart2", 600, 300, false, true); //Now, create a Line 2D Chart echo renderChart("../../FusionCharts/Line.swf", "Data/Data.xml", "", "chart3", 600, 300, false, true); I am not able to undertand "Data/Data.xml" , because here i dn't have any direct XML file , XML is getting rendered dynamically in php pages ( test1.php , test2.php). in this case how can i pass the XML to render chart in differet page. Thank you. Share this post Link to post Share on other sites
Phanik18 Report post Posted September 15, 2011 Hi Radis , Thanks for the help. i am using the bewlow code in test7.php <?php include('test3.php'); include('test6.php'); echo renderChart("Charts/StackedColumn3D.swf", "", $strXML, "productSales", 700, 500, false, false); echo renderChart("Charts/StackedColumn3D.swf", "", $strXML, "productSales1", 700, 500, false, false); echo renderChart("Charts/Pie3D.swf", "", $strXML1, "productSales2", 700, 500, false, false); ?> $strXML1 is the xml content from test6.php This is rendering the only two Stack charts , the pie chart is not getting displayed Thank you Hi, Thank you for the mail. The XML data document is stored in a PHP variable "strXML" using string concatenation . Create the chart and set the dataStr parameter as strXML. We leave dataUrl parameter blank. echo renderChart("../../FusionCharts/Column3D.swf", "", $strXML , "chart1", 600, 300, false, true); //Now, create a Column 2D Chart echo renderChart("../../FusionCharts/Column2D.swf", "", $strXML , "chart2", 600, 300, false, true); //Now, create a Line 2D Chart echo renderChart("../../FusionCharts/Line.swf", "",$strXML , "chart3", 600, 300, false, true); I hope this helps. Share this post Link to post Share on other sites
Swarnam Report post Posted September 15, 2011 Hi Phanik, Thank you for the mail. Could you please ensure Pie3D.swf file is present the Charts folder? Hi Radis , Thanks for the help. i am using the bewlow code in test7.php <?php include('test3.php'); include('test6.php'); echo renderChart("Charts/StackedColumn3D.swf", "", $strXML, "productSales", 700, 500, false, false); echo renderChart("Charts/StackedColumn3D.swf", "", $strXML, "productSales1", 700, 500, false, false); echo renderChart("Charts f", "", $strXML1, "productSales2", 700, 500, false, false); ?> $strXML1 is the xml content from test6.php This is rendering the only two Stack charts , the pie chart is not getting displayed Thank you Share this post Link to post Share on other sites
Guest Angshu Report post Posted September 15, 2011 Hi, Thanks for your response. Please make sure the paths of test3.php and test6.php is relative to the actual path of test7.php. Please send us the screenshot of the error you are getting instead of pie chart. Awaiting for your response. Share this post Link to post Share on other sites
Phanik18 Report post Posted September 15, 2011 Hi , Thanks all for the support. Radis : Pie3D.swf is preset in the charts folder and test6.php is rendering teh chart if i open it individually. Angshu : I have attched the folder structure , i am not gettign any error except PIE chart is not displayed Share this post Link to post Share on other sites
Phanik18 Report post Posted September 16, 2011 Can some one please help me. Hi , Thanks all for the support. Radis : Pie3D.swf is preset in the charts folder and test6.php is rendering teh chart if i open it individually. Angshu : I have attched the folder structure , i am not gettign any error except PIE chart is not displayed Share this post Link to post Share on other sites