Thibaut Report post Posted May 12, 2011 Hi everybody, I have a big problem : I'm using code igniter framework and i want to insert FC graphics ! I have already used FC in other website created without framework and it's very great ! I located FusionChart.js in a javascript directory and FusionCharts.php is renamed as FusionCharts_helper.php and is located in helper directory. My controller : class Chart extends CI_Controller { public function __construct() { parent::__construct() ; } public function index() { $this->load->helper(array('url','fusioncharts')) ; $graph_swfFile = base_url().'Charts/Column3D.swf' ; $graph_width = 450 ; $graph_height = 250 ; // Store Name of Products $arrData[0][1] = "Product A"; $arrData[1][1] = "Product B"; $arrData[2][1] = "Product C"; //Store sales data $arrData[0][2] = 567500; $arrData[1][2] = 815300; $arrData[2][2] = 556800; $strXML = "<graph caption='Test' numberPrefix=' formatNumberScale='0' decimalPrecision='0'>"; //Convert data to XML and append foreach ($arrData as $arSubData) { $strXML .= "<set name='" . $arSubData[1] . "' value='" . $arSubData[2] . "' color='".getFCColor()."' />"; } //Close <chart> element $strXML .= "</graph>"; $data['graph'] = renderChart($graph_swfFile, '', $strXML, 'div' , $graph_width, $graph_height, false, false); $this->load->view('chart_view',$data) ; } } my view : <!DOCTYPE html> <html> <head> <title>Untitled</title> <script language="javascript" type="text/javascript" src="<?php echo base_url(); ?>javascript/FusionCharts.js"> </head> <body> <?php echo $graph ; ?> </body> </html> My view source code after refreshing page is : <!DOCTYPE html> <html> <head> <title>Untitled</title> <script language="javascript" type="text/javascript" src="http://localhost/FFA/javascript/FusionCharts.js"> </head> <body> <!-- START Code Block for Chart div --> <div id="divDiv">Chart</div><script type="text/javascript" > <!-- // Instantiate the Chart var chart_div = new FusionCharts( { "swfUrl" : "http://localhost/FFA/Charts/Column3D.swf", "width" : "450", "height" : "250", "renderAt" : "divDiv", "dataFormat" : "xml", "id" : "div", "dataSource" : "<graph caption='Test' numberPrefix=' formatNumberScale='0' decimalPrecision='0'><set name='Product A' value='567500' color='AFD8F8' /><set name='Product B' value='815300' color='F6BD0F' /><set name='Product C' value='556800' color='8BBA00' /></graph>" } ).render(); // --></script> <!-- END Script Block for Chart div --> </body> </html> the link of FusionCharts.js is ok like the swfUrl. The code seems to be ok but my page is blank ! What is the problem ? Best reguards Thibaut Share this post Link to post Share on other sites
Guest Angshu Report post Posted May 12, 2011 Hi, Welcome to FusionCharts Forum! First of all, we would like to thank you for showing interest in FusionCharts. I am afraid, FusionCharts does not support code igniter framework, at this time. Since, it is a PHP framework and FusionCharts can be integrated with PHP, we can implement this later on our future upgrades. Thank you very much for your continued patience and patronage. Hope you have a great day! Share this post Link to post Share on other sites
Thibaut Report post Posted May 12, 2011 ah ok ! so what framework do you recommend to use FC ? thanks for the fast answer ! ;-) Share this post Link to post Share on other sites
Guest Angshu Report post Posted May 12, 2011 Hi, Thanks for your appreciation. You can use Joomla to use FusionCharts, at this time. For more details, please visit the links below: http://www.fusioncharts.com/joomla/ http://www.fusioncharts.com/joomla/docs/FCJoomla_Docs.pdf Hope this helps. Share this post Link to post Share on other sites
Gieart Report post Posted October 16, 2011 Ohh.. i'm very sad to here that.. Is there anyway to integrate with CI > 2.0 ?? I'have create my project with CI 2.0.2 Help me.. Hi, Welcome to FusionCharts Forum! First of all, we would like to thank you for showing interest in FusionCharts. I am afraid, FusionCharts does not support code igniter framework, at this time. Since, it is a PHP framework and FusionCharts can be integrated with PHP, we can implement this later on our future upgrades. Thank you very much for your continued patience and patronage. Hope you have a great day! Share this post Link to post Share on other sites
Jason Locashio Report post Posted December 21, 2011 (edited) This is a bit late, but there are a few good posts in the CodeIgniter Wiki that discuss how to get FC to work within CI. Generally speaking, you need to move the fusioncharts_gen.php into a directory inside the helper directory of your app, then create a fusioncharts_helper.php in the helper directory itself. This file should have something similar to the following: function Fusioncharts( $chartType,$width,$height,$chartID,$isTransparent ){ require_once( 'fusion/FusionCharts_Gen.php' ); $FC = new FusionCharts( $chartType, $width, $height, $chartID, $isTransparent ); $FC->setSWFPath("/path/to/your/swf/files/"); return $FC; } Now, you can call that helper from within the controller methods of you app like so: $this->load->helper('fusioncharts'); //loads the helper $sampleChartFC = Fusioncharts("ScrollStackedColumn2D", $chartWidth, "300", "leadsPerProgram", "true"); //instantiate a new FC object $strParam='caption='. $srcData['client'] .' Overall Leads;xAxisName=Programs;yAxisName=# of Leads/Hot Leads;useRoundEdges=1;'; //string of chart parameters $sampleChartFC->setChartParams($strParam); //add the params to your chart object $sampleChartFC->addChartDataFromArray($overviewData['leadsPerProgram'], $overviewData['programTitles'] ); //Load your chart data from an array into the object $outputData['sampleChart'] = $sampleChartFC->renderChart(false); //render the chart into a php var You would then pass that php var to your view via $this->load->view, and echo out the chart in your view file so it is displayed. You will, obviously, need to have the FusionCharts.js file loading in the head section of your view. Hope this helps. Edited December 21, 2011 by Jason Locashio Share this post Link to post Share on other sites
Guest Angshu Report post Posted December 22, 2011 Hi, Welcome to FusionCharts Forum! Thank you very much for sharing the solution. Happy FusionCharting! Share this post Link to post Share on other sites