sruder Report post Posted February 19, 2010 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 Report post Posted February 22, 2010 (edited) Hi, In case you are using Scatter Chart could you please try specifying the xAxisMinValue and xAxisMaxValue attributes? Hope this helps. Edited February 22, 2010 by Guest Share this post Link to post Share on other sites
srividya_sharma Report post Posted February 22, 2010 (edited) Or, you could probably use a scroll chart Or, use Limit in your sql query. Srividya Edited February 22, 2010 by Guest Share this post Link to post Share on other sites
sruder Report post Posted February 22, 2010 Thanks very much! Can xAxisMaxValue work for Date formats? Share this post Link to post Share on other sites
sruder Report post Posted February 22, 2010 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
srividya_sharma Report post Posted February 22, 2010 Hi Shawn, Can you share the generated xml with us? You can get the xml from debugMode or using println. Srividya Share this post Link to post Share on other sites
srividya_sharma Report post Posted February 22, 2010 Also, please verify that you have the swf file ScrollColumn2D.swf in the path. Share this post Link to post Share on other sites
sruder Report post Posted February 23, 2010 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 Report post Posted February 23, 2010 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
sruder Report post Posted February 23, 2010 Does the Scroll chart require an XML file to work? Share this post Link to post Share on other sites
srividya_sharma Report post Posted February 23, 2010 (edited) 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 February 23, 2010 by Guest Share this post Link to post Share on other sites
sruder Report post Posted February 23, 2010 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
srividya_sharma Report post Posted February 23, 2010 (edited) 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 February 23, 2010 by Guest Share this post Link to post Share on other sites
Ayan Pal Report post Posted February 24, 2010 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
sruder Report post Posted February 26, 2010 Thanks for the help everybody! I think that we have it working now! Share this post Link to post Share on other sites
Guest Basundhara Ghosal Report post Posted February 28, 2010 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