Phanik18

Rendering Multiple Charts Into Single Html \ Php Page

Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now