sruder

Limit Data Shown

Recommended Posts

I am showing weekly numbers for clients and have an odd problem - too much data to show!

 

 

 

Any thoughts on how I can show simply the last x number of weeks as opposed to everything we have?

 

 

 

Here is the code:

 

 

 

# Define chart attributes

 

$strParam="caption=Customer Pay Hours Per Ro" . $WeeklyData . " Output;subcaption=HRs Per RO;xAxisName=Week End Date; formatNumberScale=0;decimals=2;rotateLabels=1;slantLabels=1";

 

 

 

# Set chart attributes

 

$FC->setChartParams($strParam);

 

 

 

 

 

// Fetch all factory records usins SQL Query

 

//Store chart data values in 'total' column/field and category names in 'FactoryName'

 

$strQuery = "select CP_HRs,WeekEndDate from " .$x->QueryFrom . ' ' . $x->QueryWhere . ' ' . " order by WeekEndDate";

 

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

 

 

 

//Pass the SQL Query result to the FusionCharts PHP Class function

 

//along with field/column names that are storing chart values and corresponding category names

 

//to set chart data from database

 

if ($result) {

 

$FC->addDataFromDatabase($result, "CP_HRs", "WeekEndDate");

 

}

 

mysql_close($link);

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

In case you are using Scatter Chart could you please try specifying the xAxisMinValue and xAxisMaxValue attributes?

Hope this helps. :)

Edited by Guest

Share this post


Link to post
Share on other sites

Just as another follow up - on the scroll chart, which I think is the way to go!

 

 

 

However, when I set it up it says there is "No Data to Display" - guess I am not sure how it is different for the scroll 2d vs. the regular 2d.

 

 

 

Here is the code to pull it from the database:

 

 

 

$FC = new FusionCharts("ScrollColumn2D","1100","450");

 

 

 

# Set Relative Path of swf file.

 

$FC->setSWFPath("http://www.autoublog.com/service_data/FusionCharts_Developer/Charts/");

 

 

 

# Define chart attributes

 

$strParam="caption=Customer Pay Hours Per Ro" . $WeeklyData . " Output;subcaption=HRs Per RO;xAxisName=Week End Date";

 

 

 

# Set chart attributes

 

$FC->setChartParams($strParam);

 

 

 

 

 

// Fetch all factory records usins SQL Query

 

//Store chart data values in 'total' column/field and category names in 'FactoryName'

 

$strQuery = "select CP_HRs,WeekEndDate from " .$x->QueryFrom . ' ' . $x->QueryWhere . ' ' . " order by WeekEndDate DESC ";

 

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

 

 

 

//Pass the SQL Query result to the FusionCharts PHP Class function

 

//along with field/column names that are storing chart values and corresponding category names

 

//to set chart data from database

 

if ($result) {

 

$FC->addDataFromDatabase($result, "CP_HRs", "WeekEndDate");

 

}

 

mysql_close($link);

 

 

 

# Render the chart

 

$FC->renderChart();

 

 

 

Thanks!

 

Shawn

Share this post


Link to post
Share on other sites

Thanks again for replying.

 

 

 

The SWF file is fine that is where they are located.

 

 

 

However, I guess the issue is that I am not sure there is an XML generated. This code works for the 'non' scroll SWF file - so thought it work for the scroll one too.

 

 

 

Shawn

Share this post


Link to post
Share on other sites
Guest Rajroop

Hi Shawn,

 

 

 

I would have to ask you to perform some checks on the following points here.

 

 

 

> Could you please send us the generated XML using the debug window? Please refer to the following link to know more about how to manipulate the debug window to obtain the XML of the chart.

 

Ref.- http://www.fusioncharts.com/docs/Contents/Debug/window.html

 

 

 

> In case, you face difficulty in achieving the above, could you please make sure that you are incorporating the <set> elements within a <dataset> element, that is, in a Multi-series XML format? The Scroll chart correspond to the Mutli-series XML format and not the Single-series XML format.

 

Ref.- http://www.fusioncharts.com/docs/Contents/ChartSS/Column2D.html#sampleXML

 

 

 

Looking forward to your post in this regard.

Share this post


Link to post
Share on other sites

Hi Shawn,

All the charts use xml file for rendering the data.

Using php API , the generation of xml is done behind the scenes.

ScrollColumn2D is considered to be multi-series. So you would need to provide dataset and categories.

You would need to tweak the code slightly.

Just as Rajroop said, you would need to add category and dataset just before adding chart data from database.

Something of this sort:

# Add category names

  $FC->addCategory("Week 1");

 

# Create a new dataset

  $FC->addDataset("This Month");

Please refer to the following page for more details on this:

http://www.fusioncharts.com/docs/Contents/PHPClassAPI/MultiSeriesChart.html

Srividya :)

Edited by Guest

Share this post


Link to post
Share on other sites

Thanks again everybody!

 

 

 

Now, I have the start of the a chart - though it only shows one bar when there should be many... any other suggestions?

 

 

 

Code here:

 

 

 

 

 

$FC = new FusionCharts("ScrollColumn2D","1100","450", "0", "0");

 

 

 

# Set Relative Path of swf file.

 

$FC->setSWFPath("http://www.autoublog.com/service_data/FusionCharts_Developer/Charts/");

 

 

 

# Define chart attributes

 

$strParam="caption=Customer Pay Hours Per Ro" . $WeeklyData . " Output;subcaption=HRs Per RO;xAxisName=Week End Date;showValues=0";

 

 

 

# Set chart attributes

 

$FC->setChartParams($strParam);

 

 

 

# Add category names

 

$FC->addCategory("Week 1");

 

 

 

# Create a new dataset

 

$FC->addDataset("This Month");

 

 

 

 

 

// Fetch all factory records usins SQL Query

 

//Store chart data values in 'total' column/field and category names in 'FactoryName'

 

$strQuery = "select CP_HRs,WeekEndDate from " .$x->QueryFrom . ' ' . $x->QueryWhere . ' ' . " order by WeekEndDate DESC ";

 

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

 

 

 

//Pass the SQL Query result to the FusionCharts PHP Class function

 

//along with field/column names that are storing chart values and corresponding category names

 

//to set chart data from database

 

if ($result) {

 

$FC->addDataFromDatabase($result, "CP_HRs", "WeekEndDate");

 

}

 

mysql_close($link);

 

 

 

# Render the chart

 

$FC->renderChart();

Share this post


Link to post
Share on other sites

Hi Shawn,

Since you are getting the data dynamically from the database, you would need to parse the result set and add the categories and sets dynamically.

I have modified your code, please try it out.

$FC = new FusionCharts("ScrollColumn2D","1100","450", "0", "0");

# Set Relative Path of swf file.
$FC->setSWFPath("http://www.autoublog.com/service_data/FusionCharts_Developer/Charts/");

# Define chart attributes 
$strParam="caption=Customer Pay Hours Per Ro" . $WeeklyData . " Output;subcaption=HRs Per RO;xAxisName=Week End Date;showValues=0";

# Set chart attributes
$FC->setChartParams($strParam);



# Create a new dataset 
//$FC->addDataset("This Month"); // this is not required.


// Fetch all factory records usins SQL Query
//Store chart data values in 'total' column/field and category names in 'FactoryName'
$strQuery = "select CP_HRs,WeekEndDate from " .$x->QueryFrom . ' ' . $x->QueryWhere . ' ' . " order by WeekEndDate DESC ";
$result = mysql_query($strQuery) or die(mysql_error());

//Iterate through each row
if ($result) {
while($ors = mysql_fetch_array($result)) {
# Add category names
$FC->addCategory($ors['CP_HRs']);
//Here, you can convert date into a more readable form.
# Add chart data
$FC->addChartData($ors['WeekEndDate']);
}
}

mysql_close($link);

# Render the chart
$FC->renderChart(); 

Please try it out. Thanks.

Srividya :)

Edited by Guest

Share this post


Link to post
Share on other sites

Hi Shawn,

 

 

 

Since you are adding 1 category

 

# Add category names

 

$FC->addCategory("Week 1");

 

 

 

and 1 dataset

 

# Create a new dataset

 

$FC->addDataset("This Month");

 

that's why its generating 1 column.

 

 

 

May be you have more than 1 set on that dataset but it will show first one as it map to the given category.

 

 

 

To solve this, you can:

 

 

 

1. Add enough category(may be blank) to show all the set tag in that dataset(if you have more than 1 set in the dataset "This Month")

 

2. You can use our FusionCharts PHP Class API ("FusionCharts_Gen.php") to dynamically add category and dataset from database

 

 

 

P.s: You may refer to the attached sample ('modify this as per your database/requirement').

 

 

 

Hope this helps you.

BasicDBExample.zip

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

Thanks for your appreciation.

Glad to know that your issue is resolved.

Happy FusionCharting.

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