Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Code Igniter with Fusion Chart
#1

[eluser]souri84[/eluser]
Hi everybody,

I tested all over methods listed in the search part of the forum but none works ! And this method that I'm using provides from the website : http://kohaci.com/2010/10/26/update-fusi...niter.html

I located FusionChart.js in a javascript directory and FusionCharts.php is renamed as FusionCharts_helper.php and is located in application/helpers directory.

My controller :

Code:
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 :

Code:
<!DOCTYPE html>
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Untitled&lt;/title&gt;
    [removed]
    
&lt;/head&gt;

&lt;body&gt;


&lt;?php
echo $graph ;
?&gt;

&lt;/body&gt;
&lt;/html&gt;



My view source code after refreshing page is :

Code:
<!DOCTYPE html>
        &lt;html&gt;
                &lt;head&gt;
                        &lt;title&gt;Untitled&lt;/title&gt;
                        [removed]
                &lt;/head&gt;
                &lt;body&gt;
                        &lt;!-- START Code Block for Chart div --&gt;
                        <div id="divDiv">Chart</div>[removed]
                        &lt;!--    // 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();
                        // --&gt;[removed]
                        &lt;!-- END Script Block for Chart div --&gt;
                &lt;/body&gt; &lt;/html&gt;


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
#2

[eluser]toopay[/eluser]
Did your swfUrl pointing to the right path?
#3

[eluser]souri84[/eluser]
yeah, it's the right path !
#4

[eluser]toopay[/eluser]
I look at your rendered page source code, and i think your javascript statement
Code:
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();
should wrapped with script tag.
#5

[eluser]souri84[/eluser]
ok ! thanks but how can I do wrapp this line with script tag ?

big thanks !
#6

[eluser]toopay[/eluser]
at your view file
Code:
// remove '\'. Cant post script tag here.
<\script>
&lt;?php echo $graph ?&gt;
<\/script>
#7

[eluser]souri84[/eluser]
it seems to be wrong... sorry :-(
#8

[eluser]toopay[/eluser]
Hahaha, dont apologize for that. How your page source looks like now?
#9

[eluser]souri84[/eluser]
it's the same... blanck ! ;-)
#10

[eluser]toopay[/eluser]
Your page's source (CTRL+U on your browser), how its look like? Is there any difference with the first one you post above?




Theme © iAndrew 2016 - Forum software by © MyBB