Sign in to follow this  
Eilons

Scrollcolumn2D With My Sql

Recommended Posts

Hey everyone!

 

I read alot of comments and posts about this subjects but I still can't to make it working.

 

I'm trying to make ScrollColumn2D with Month as Xaxisname and revenue in Yaxisname.

I'm doing an sql query and it's work but i cant pass the parameter with xml data to the chart.

 

the code:

 

 

 

 

<?php

include("FusionCharts_Evaluation/Code/PHP/Includes/FusionCharts.php");

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>

<head>

<title> </title>

<script LANGUAGE="Javascript" SRC="FusionCharts_Evaluation/Charts/FusionCharts.js"></SCRIPT>

</head>

<body>

 

 

<?PHP

 

$host="localhost";

$user="root";

$password="";

$database="my_db";

 

// connect to database

mysql_connect($host, $user, $password)

or die ('Unable to connect to server.');

 

mysql_select_db($database)

or die ('Unable to select database.');

 

date_default_timezone_set('Asia/Tel_Aviv');

 

/*$year=$_POST["year"];*/

$StartYear= date("2011-01-01");

$EndYear= date("2011-12-31");

 

 

$strXML="<chart caption='Business Results 2005 v 2006' xAxisName='Month' yAxisName='Revenue' showValues='0' numberPrefix='$' useRoundEdges='1' legendBorderAlpha='100' showBorder='0' bgColor='FFFFFF,FFFFFF' >";

 

$result = mysql_query ("select BEGIN_DATE from linkage where BEGIN_DATE >= '$StartYear' AND BEGIN_DATE <= '$EndYear' order by BEGIN_DATE");

if (mysql_num_rows($result)>1) /*due to the fact that mysql_data_seek rerutn error if there is no result returned*/

{

$j=0;

$data=array();

for($i=1; $i<=12; $i++)

{

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

$RowToDate=strtotime($row['BEGIN_DATE']);

$RowToMonth=date('n',$RowToDate);

if ($RowToMonth == $i) $j=$j+1;

}

$data[]=intval($j);

$j=0;

mysql_data_seek($result, 0); /*in order to go more than once on result*/

}

}

else $data=array(0,0,0,0,0,0,0,0,0,0,0,0);

 

$labels[0]="Jan";

$labels[1]="Feb";

$labels[2]="Mar";

$labels[3]="Apr";

$labels[4]="May";

$labels[5]="Jun";

$labels[6]="Jul";

$labels[7]="Aug";

$labels[8]="Sep";

$labels[9]="Oct";

$labels[10]="Nov";

$labels[11]="Dec";

 

 

 

for($i=0; $i< sizeof($data); $i++) {

$strXML .= "<category label='" . $labels[$i] . "' value='" . $data[$i] . "' />";

}

 

mysql_close();

$strXML .="</chart>";

echo renderChart("FusionCharts_Evaluation/Charts/ScrollColumn2D.swf", "", $strXML, "FactorySum", 600, 300, false, true);

 

 

?>

 

 

</body>

</html>

 

 

 

please help!

 

 

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 test it from our end?

 

The XML code can be found from the view-source menu of the browser.

 

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.

 

More details at: http://www.fusioncharts.com/docs/?guide-for-web-developers/php/PHP_DB.html

 

Hope this helps.

Share this post


Link to post
Share on other sites

Hi!

 

first of all thank you for your answer!

 

Here is the generated XML code:

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd">

 

 

<HTML>

 

 

<head>

 

 

<title> </title>

 

 

<script LANGUAGE="Javascript" SRC="FusionCharts_Evaluation/Charts/FusionCharts.js"></SCRIPT>

 

 

</head>

 

 

<body>

 

 

 

<!-- START Code Block for Chart FactorySum -->

 

<

 

 

div id="FactorySumDiv">Chart</div>

 

<

 

 

script type="text/javascript" ><!--

 

 

// Instantiate the Chart

 

 

if ( FusionCharts("FactorySum") && FusionCharts("FactorySum").dispose ) FusionCharts("FactorySum").dispose();

 

 

var chart_FactorySum = new FusionCharts( { "swfUrl" : "FusionCharts_Evaluation/Charts/ScrollColumn2D.swf", "width" : "600", "height" : "300", "renderAt" : "FactorySumDiv", "dataFormat" : "xml", "id" : "FactorySum", "dataSource" : "<chart caption='Business Results 2005 v 2006' xAxisName='Month' yAxisName='Revenue' showValues='0' numberPrefix='$' useRoundEdges='1' legendBorderAlpha='100' showBorder='0' bgColor='FFFFFF,FFFFFF' ><category label='Jan' value='2' /><category label='Feb' value='3' /><category label='Mar' value='0' /><category label='Apr' value='1' /><category label='May' value='0' /><category label='Jun' value='0' /><category label='Jul' value='0' /><category label='Aug' value='2' /><category label='Sep' value='2' /><category label='Oct' value='0' /><category label='Nov' value='0' /><category label='Dec' value='2' /></chart>" } ).render();

 

// -->

 

 

</script>

 

<!-- END Script Block for Chart FactorySum -->

 

 

 

</

 

 

body>

 

 

</html>

 

 

one more thing, where can I find an example of a proper XML for scrollcolumn2D??

 

 

 

Thanks!

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Thanks for your response.

 

It seems from your code that the XML data has not been properly defined.

 

To know about the XML data format Of FusionCharts and examples, please visit the links below:

 

http://www.fusioncharts.com/docs/?DataFormats/XML/SingleSeries.html

 

http://www.fusioncharts.com/docs/?DataFormats/XML/MultiSeries.html

 

For example of ScrollColumn2D XML, please refer : http://www.fusioncharts.com/docs/?ChartSS/ScrollColumn2D.html

 

Hope this helps.

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