Welcome Guest, Not a member yet? Register   Sign In
Install FusionChart on CI as plugin Plugin
#1

[eluser]Amjith or Cool Coder[/eluser]
Hi,
Note: Please delete space between the links of fusionchart. eg: you will find space after http: (http: //).
http: //www.fusioncharts.com/free/Overview.asp?gMenuItemId=2
If you feels difficult to use it, Please follow below steps.
1. Download Fusionchart http: //www.fusioncharts.com/free/Download.asp?gMenuItemId=5
2. Unzip, Folder
3. Copy folder 'Charts' to root of your CI Project
4. If you are using .htaccess ,
open file and add Charts 'RewriteCond' ,
example will be
Code:
RewriteCond $1 ^(index\.php|Charts)
5. Open folder 'Code/PHP'
You will find a list of folders showing php examples on how to create fusion charts. Its really helpful for development. Before we can add a plugin module to the CI

a. add a new file 'fusionchart_pi.php' on your CI Project folder 'system/plugins/'
add this lines of code to that file

Code:
<?php
function encodeDataURL($strDataURL, $addNoCacheStr=false) {
    if ($addNoCacheStr==true) {
                                if (strpos(strDataURL,"?")<>0)
                                            $strDataURL .= "&FCCurrTime;=" . Date("H_i_s");
                                else
                                            $strDataURL .= "?FCCurrTime=" . Date("H_i_s");
                 }
                return urlencode($strDataURL);
}
function datePart($mask, $dateTimeStr) {
    @list($datePt, $timePt) = explode(" ", $dateTimeStr);
    $arDatePt = explode("-", $datePt);
    $dataStr = "";
    if (count($arDatePt) == 3) {
        list($year, $month, $day) = $arDatePt;
        switch ($mask) {
        case "m": return (int)$month;
        case "d": return (int)$day;
        case "y": return (int)$year;
        }
           return (trim($month . "/" . $day . "/" . $year));
    }
    return $dataStr;
}
function renderChart($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight) {
    if ($strXML=="")
        $tempData = "//Set the dataURL of the chart\n\t\tchart_$chartId.setDataURL(\"$strURL\")";
    else
        $tempData = "//Provide entire XML data using dataXML method\n\t\tchart_$chartId.setDataXML(\"$strXML\")";
                    $chartIdDiv = $chartId . "Div";
                                $render_chart = <<<RENDERCHART
                                                                                        &lt;!-- START Script Block for Chart $chartId --&gt;
                                                                                        <div id="$chartIdDiv" align="center">
                                                                                            Chart.
                                                                                        </div>
                                                                                        [removed]    
                                                                                            //Instantiate the Chart    
                                                                                            var chart_$chartId = new FusionCharts("$chartSWF", "$chartId", "$chartWidth", "$chartHeight");
                                                                                           $tempData
                                                                                            //Finally, render the chart.
                                                                                            chart_$chartId.render("$chartIdDiv");
                                                                                        [removed]    
                                                                                        &lt;!-- END Script Block for Chart $chartId --&gt;
RENDERCHART;
  return $render_chart;
}
function renderChartHTML($chartSWF, $strURL, $strXML, $chartId, $chartWidth, $chartHeight) {
    $strFlashVars = "&chartWidth;=" . $chartWidth . "&chartHeight;=" . $chartHeight ;
    if ($strXML=="")
        $strFlashVars .= "&dataURL;=" . $strURL;
    else
        $strFlashVars .= "&dataXML;=" . $strXML;
$HTML_chart = <<&lt;HTMLCHART
    &lt;!-- START Code Block for Chart $chartId --&gt;
    &lt;OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"  width="$chartWidth" height="$chartHeight" id="$chartId">
        <param name="allowScriptAccess" value="always" />
        <param name="movie" value="$chartSWF"/>        
        <param name="FlashVars" value="$strFlashVars" />
        <param name="quality" value="high" />
        &lt;embed src="$chartSWF" FlashVars="$strFlashVars" quality="high" width="$chartWidth" height="$chartHeight" name="$chartId" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /&gt;
    &lt;/object&gt;
    &lt;!-- END Code Block for Chart $chartId --&gt;
HTMLCHART;
  return $HTML_chart;
}
function boolToNum($bVal) {
    return (($bVal==true) ? 1 : 0);
}
?&gt;
6. Copy 'JSClass/FusionCharts.js' from fussion chart folder to your CI javascripts folder
7. Call plugin on your controller ($this->load->plugin('fusionchart'))
8. Add javascript to your view
9. On your view file,
Code:
&lt;?php echo renderChart(site_url("Charts/FCF_Line.swf"), $XML_DATA, "", "chart1", 230, 130);?&gt;
for line graph
$XML_DATA is the variable where xml data is stored as file. for reference regarding XML formats please refer
http: //www.fusioncharts.com/free/docs/?gMenuItemId=19
10 You are done.

Thanks and hope everything works good.

My next post will be of creating Fusionchart library on CI.


Messages In This Thread
Install FusionChart on CI as plugin Plugin - by El Forum - 11-14-2008, 12:06 AM
Install FusionChart on CI as plugin Plugin - by El Forum - 11-14-2008, 08:11 AM
Install FusionChart on CI as plugin Plugin - by El Forum - 11-14-2008, 10:16 AM
Install FusionChart on CI as plugin Plugin - by El Forum - 03-17-2009, 11:00 AM
Install FusionChart on CI as plugin Plugin - by El Forum - 03-17-2009, 11:05 AM
Install FusionChart on CI as plugin Plugin - by El Forum - 11-25-2009, 03:44 AM
Install FusionChart on CI as plugin Plugin - by El Forum - 01-28-2010, 07:46 AM
Install FusionChart on CI as plugin Plugin - by El Forum - 01-28-2010, 08:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB