PUDYASTO

Multiseries Chart With Php Mysql

Recommended Posts

Whats wrong with my code :

 

<?Php

include ("koneksi.Php"); //connect to server

include("FusionCharts.php");

$strXML = "<chart caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' showValues='1' showlegend='1' legendPosition='bottom' formatNumberScale='0' showBorder='1'>";

 

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

$strQuery = "SELECT SUM(qty) AS TotOutput,SUM(qty) + SUM(qty) AS TotOutput2,kd_brg FROM tjualtempjateng

WHERE kd_brg BETWEEN '1-01-05-005-001' AND '2-01-02-01-0020'

GROUP BY kd_brg ORDER BY kd_brg";

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

 

$strCategories = "<categories>";

while($ors2 = mysql_fetch_array($result2)){

$strCategories .= "<category name='" . $ors2['kd_brg'] . "' />"; }

$strCategories .= "</categories>";

 

$strDataCurr = "<dataset seriesName='TotOutput'>";

while($ors2 = mysql_fetch_array($result2)){

$strDataCurr .= "<set value='" . $ors2['TotOutput'] . "' />"; }

$strDataCurr .= "</dataset>";

 

$strDataCurr2 = "<dataset seriesName='TotOutput2'>";

while($ors2 = mysql_fetch_array($result2)){

$strDataCurr2 .= "<set value='" . $ors2['TotOutput2'] . "' />"; }

$strDataCurr2 .= "</dataset>";

 

 

mysql_free_result($result2);

 

//Finally, close <chart> element

$strXML .= $strCategories . $strDataCurr . $strDataCurr2 . "</chart>";

echo renderChartHTML("Charts/MSColumn3D.swf", "", $strXML, "myNext", 1200, 500, false);

?>

 

 

this result is empty chart, can you solve my problem?

post-20028-0-89154100-1312534595_thumb.jpg

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

Could you please send us the generated XML code to look into the issue?

 

The XML generation process of multi-series chart is same as single-series chart, All you need to do is to build proper XML from the database that you query from your database.

 

Multi-series charts have a different data format from the format of an XML for a single-series chart like pie.

 

To know about multi-series chart data format, please visit the link: http://www.fusioncha...ultiSeries.html

 

Hope this helps.

Share this post


Link to post
Share on other sites

I try to create xml from variable of php, like this

 

$strXML = "<chart caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' showValues='1' showlegend='1' legendPosition='bottom' formatNumberScale='0' showBorder='1'>";

 

$strQuery = "SELECT SUM(qty) AS TotOutput,SUM(qty) + SUM(qty) AS TotOutput2,kd_brg FROM tjualtempjateng

WHERE kd_brg BETWEEN '1-01-05-005-001' AND '2-01-02-01-0020'

GROUP BY kd_brg ORDER BY kd_brg";

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

 

 

 

$strCategories = "<categories>"; // as <categories>

while($ors2 = mysql_fetch_array($result2)){

$strCategories .= "<category name='" . $ors2['kd_brg'] . "' />"; }

$strCategories .= "</categories>"; // as </categories>

 

 

 

$strDataCurr = "<dataset seriesName='TotOutput'>"; // as <dataset>

while($ors2 = mysql_fetch_array($result2)){

$strDataCurr .= "<set value='" . $ors2['TotOutput'] . "' />"; }

$strDataCurr .= "</dataset>"; // as </dataset>

 

 

 

 

$strDataCurr2 = "<dataset seriesName='TotOutput2'>"; // as <dataset>

while($ors2 = mysql_fetch_array($result2)){

$strDataCurr2 .= "<set value='" . $ors2['TotOutput2'] . "' />"; }

$strDataCurr2 .= "</dataset>"; // as </dataset>

 

 

 

 

mysql_free_result($result2);

 

$strXML .= $strCategories . $strDataCurr . $strDataCurr2 . "</chart>";

 

 

 

so, my xml is same as $strXml,

For dataset1 is TotOutput and dataset2 is TotOutput2.

For data from dataset I use looping from execute $strQuery

 

(sorry if my english is not well)

Share this post


Link to post
Share on other sites

I try to create xml from variable of php, like this

 

$strXML = "<chart caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' showValues='1' showlegend='1' legendPosition='bottom' formatNumberScale='0' showBorder='1'>";

 

$strQuery = "SELECT SUM(qty) AS TotOutput,SUM(qty) + SUM(qty) AS TotOutput2,kd_brg FROM tjualtempjateng

WHERE kd_brg BETWEEN '1-01-05-005-001' AND '2-01-02-01-0020'

GROUP BY kd_brg ORDER BY kd_brg";

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

 

 

 

$strCategories = "<categories>"; // as <categories>

while($ors2 = mysql_fetch_array($result2)){

$strCategories .= "<category name='" . $ors2['kd_brg'] . "' />"; }

$strCategories .= "</categories>"; // as </categories>

 

 

 

$strDataCurr = "<dataset seriesName='TotOutput'>"; // as <dataset>

while($ors2 = mysql_fetch_array($result2)){

$strDataCurr .= "<set value='" . $ors2['TotOutput'] . "' />"; }

$strDataCurr .= "</dataset>"; // as </dataset>

 

 

 

 

$strDataCurr2 = "<dataset seriesName='TotOutput2'>"; // as <dataset>

while($ors2 = mysql_fetch_array($result2)){

$strDataCurr2 .= "<set value='" . $ors2['TotOutput2'] . "' />"; }

$strDataCurr2 .= "</dataset>"; // as </dataset>

 

 

 

 

mysql_free_result($result2);

 

$strXML .= $strCategories . $strDataCurr . $strDataCurr2 . "</chart>";

 

 

 

so, my xml is same as $strXml,

For dataset1 is TotOutput and dataset2 is TotOutput2.

For data from dataset I use looping from execute $strQuery

 

(sorry if my english is not well)

 

 

 

friend, I have a problem same as yours, if you managed to solve, please send me the answer, I need a lot.

 

thanks!

Share this post


Link to post
Share on other sites

Even I have the same problem. Could some one provide the solution with only PHP and mySQL without using XML content.

 

 

Thanks

 

 

quote name='MichelBR' timestamp='1312830443' post='39492']

friend, I have a problem same as yours, if you managed to solve, please send me the answer, I need a lot.

 

thanks!

 

 

 

Share this post


Link to post
Share on other sites
Guest Rishi Choudhari

Hi,

 

Just change this -

 

$strCategories .= "<category name='" . $ors2['kd_brg'] . "' />"; }

 

to this

 

$strCategories .= "<category label='" . $ors2['kd_brg'] . "' />"; }

Edited by Rishi Choudhari

Share this post


Link to post
Share on other sites

Now with PHP I can solve My problem to.....

This is My code and working with multiseries charts.

 

<?php

include "koneksi.php"; //Connection to Database

include "FusionCharts.php"; //Charts

 

$strXML = "<chart caption='Customers by QTY' yAxisName='QTY' xAxisName='Customers' numberPrefix='' formatNumberScale='0' rotateValues='1' placeValuesInside='1' decimals='0' >"; //Start XML Code

 

connect_db(); //Call function of connection database

$strquery = "

SELECT kdpel,

SUM(CASE WHEN kd_brg = '2-01-02-01-0005' THEN qty ELSE 0 END) AS MKIOS_05,

SUM(CASE WHEN kd_brg = '2-01-02-01-0010' THEN qty ELSE 0 END) AS MKIOS_10,

SUM(CASE WHEN kd_brg = '2-01-02-01-0020' THEN qty ELSE 0 END) AS MKIOS_20

FROM importjual

WHERE (kd_brg BETWEEN '2-01-02-01-0005' AND '2-01-02-21-0100')

AND (qty BETWEEN '1000' AND '8000')

GROUP BY kdpel

LIMIT 0,10"; //String Query database

 

$query2 = mysql_query($strquery); //call string query

 

$strCategories = "<categories>"; //create categories

while ($cat = mysql_fetch_array($query2))

{

$strCategories .= "<category label='" . $cat[0] . "' />"; //display categories

};

$strCategories .= "</categories>";

 

$query3 = mysql_query($strquery); //call string query

$K5 = "<dataset seriesName='MKIOS_05'>"; //create dataset

while ($MK5 = mysql_fetch_array($query3))

{

$K5 .= "<set value='" . $MK5[1] . "' />"; //display value of dataset

}

$K5 .= "</dataset>";

 

$query4 = mysql_query($strquery); //call string query

$K10 = "<dataset seriesName='MKIOS_10'>"; //create dataset

while ($MK10 = mysql_fetch_array($query4))

{

$K10 .= "<set value='" . $MK10[2] . "' />"; //display value of dataset

}

$K10 .= "</dataset>";

 

$query5 = mysql_query($strquery); //call string query

$K20 = "<dataset seriesName='MKIOS_20'>"; //create dataset

while ($MK20 = mysql_fetch_array($query5))

{

$K20 .= "<set value='" . $MK20[3] . "' />"; //display value of dataset

}

$K20 .= "</dataset>";

 

$strXML .= $strCategories . $K5 . $K10 . $K20 . "</chart>"; //end of XML

 

echo renderChart("Charts/MScolumn3d.swf", "", $strXML, "productSales", 1400, 500, false, false);

 

?>

 

I hope it can help your problems

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