Jason Locashio

Members
  • Content count

    2
  • Joined

  • Last visited

Everything posted by Jason Locashio

  1. Fusionchart With Code Igniter

    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.