Sign in to follow this  
nashsaint

SQL - PHP Multi-Series Chart.

Recommended Posts

Hi, I was able to create a chart using a single series but spent nights trying to create a multi-series chart with no good result. If anyone can help me with this it would be of great help.

 

 

 

Here are my tables.

 

 

 

2 SQL tables:

 

 

 

Engineers & Disks

 

 

 

ENGINEERS

 

- eng_id

 

- first_name

 

- last_name

 

 

 

DISKS

 

- job_no

 

- model_no

 

- status (value of either Complete of Fail)

 

 

 

What I would like to do is create a query that would display total number of Engineer's Complete and Fail job.

 

probably would look like this: (I only edited the image so you'll understand what i want).

 

eng.png

 

 

 

 

 

 

 

If its gonna help I also have posted the code for single series chart.

 

 

 

<

 

 

 

require_once ('./mysql_connect.php'); // Connect to the db.

 

 

 

//$strXML will be used to store the entire XML document generated

 

//Generate the chart element

 

$strXML = "";

 

 

 

//Fetch all factory records

 

$strQuery = "select * from engineers";

 

$result = mysql_query($strQuery) or die(mysql_error());

 

 

 

 

 

//Iterate through each engr

 

 

 

if ($result) {

 

while($ors = mysql_fetch_array($result)) {

 

//Now create a second query to get details for this engr

 

$strQuery = "SELECT COUNT(disk_id) AS TotOutput FROM disks WHERE eng_id=" . $ors['eng_id'];

 

$result2 = mysql_query($strQuery) or die(mysql_error());

 

$ors2 = mysql_fetch_array($result2);

 

//Generate

 

$strXML .= "";

 

//free the resultset

 

mysql_free_result($result2);

 

}

 

}

 

mysql_close(); // Close the database connection.

 

 

 

//Finally, close element

 

$strXML .= "";

 

 

 

//Create the chart - Pie 3D Chart with data from $strXML

 

echo renderChart("./charts/Column3D.swf", "", $strXML, "FactorySum", 650, 400, false, false);

 

 

 

 

 

 

Many Thanks foryour help.

Share this post


Link to post
Share on other sites

What kind of problem do you exactly have with your MS chart? Can you post the code for it here? Or have you tried turning DebugMode on to see what your xml would look like...If you are getting all the data from the database (which i think is the hardest part :-)) then the rest should be ok...unless you mess up xml formatting which the debugger will tell you about

Share this post


Link to post
Share on other sites

Hi,

For Multi-series charts the XML structure is a bit different from single series XML. Hence, would you need to design the process of fetching data from database as per the XML structure. Could you please refer to the MS XML structure from :

http://fusioncharts.com/docs/Contents/MultiSeries.html.

 

Please also refer to the code that we provide below which might suit you needs. Please note that since we do not know what value might be there in status field you might need to modify the code as per the value in it.

MS_Test.php.txt

Data.xml.txt

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
Sign in to follow this