Welcome Guest, Not a member yet? Register   Sign In
OpenFlashChart with CI
#1

[eluser]vcool[/eluser]
--moved from previous section--

Using OpenFlashChart with CI

- Download OpenFlashChart at http://teethgrinder.co.uk/open-flash-chart/

- Create directory in CI root :
Code:
assets/
         --swf/
         --js/
- Extract OpenFlashChart to temporary folder

- Copy the php-ofc-library/open-flash-chart.php file to system/application/library/ and then rename it to graph.php

- Copy the open-flash-chart.swf file to assets/swf/

- Copy the js/swfobject.js to assets/js/

- Edit file graph.php, find this following lines :
Code:
$this->js_path = 'js/';
    $this->swf_path = '';
Edit to :
Code:
$this->js_path = base_url().'assets/js/';
      $this->swf_path = base_url().'assets/swf/';

- Example :

Contoller :
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');


Class Statistic extends Controller {
    
    function Statistic(){
        parent::Controller();
        //$this->freakauth_light->check('user');
        
        //load the models
        $this->load->model('vouchermodel');
        $this->load->model('postpaidmodel');
        $this->load->model('billingplanmodel');
        $this->load->model('statisticmodel');
        
        //load radius helpers
        $this->load->helper('radius');
    }
    
    function index(){
        //security check
        $this->freakauth_light->check('user');
        
        $this->load->library('graph');
        
        //get billingplan
        $bp_qty = array();
        $bp_label = array();
        $data['billingplans'] = $this->billingplanmodel->getBillingPlanStat();
        foreach ($data['billingplans']->result() as $billingplan) {
            $bp_qty[] = $billingplan->qty;
            $bp_label[] = $billingplan->billingplan;
        }
        
        //PIE chart, 60% alpha
        //
        $this->graph->pie(80,'#505050','{font-size: 12px; color: #404040;');
        //
        // pass in two arrays, one of data, the other data labels
        //
        $this->graph->pie_values( $bp_qty, $bp_label );
        //
        // Colours for each slice, in this case some of the colours
        // will be re-used (3 colurs for 5 slices means the last two
        // slices will have colours colour[0] and colour[1]):
        //
        $this->graph->pie_slice_colours( array('#d9db35','#487daf','#d00000','#4ae331') );

        $this->graph->set_tool_tip( '#val# Vouchers' );
        $this->graph->bg_colour = '#040404';
        $this->graph->title( 'Voucher Created', '{font-size:14px; color: #7F7772}' );
        $this->graph->set_output_type('js');
        
                
        //get the vouchers data
        $data['voucher'] = $this->vouchermodel->getVoucherStatistics();
        
        //get the postpaid account data
        $data['postpaid'] =  $this->postpaidmodel->getAccountStatistic();
        
        //get the who's online list
        $data['onlineuser'] = radius_get_online_users();
        
        $data['title'] = "Hotspot Statistics";
        $data['h1'] = "Hotspot Statistics";
        
        //$this->output->enable_profiler();
        
        $this->load->view('statistic/statistic_view',$data);
    }
    
}

?>

view :
Code:
<?php $this->load->view('header') ?>

<h1>&lt;?=$h1?&gt;</h1>

<div id='voucher_info'>
<h3>Vouchers Info</h3>
<ul>
    <li><label>Vouchers Created</label>&lt;?=$voucher['created']?&gt;</li>
    <li><label>Used</label>&lt;?=$voucher['used']?&gt;</li>
    <li><label>Expired</label>&lt;?=$voucher['expired']?&gt;</li>
</ul>
<h3>Billing Plans</h3>
<ul>
    &lt;?php foreach($billingplans->result() as $row):?&gt;
    <li><label>&lt;?=$row->billingplan?&gt;</label>&lt;?=$row->qty?&gt;</li>
    &lt;?php endforeach; ?&gt;
</ul>
        <div id='graph'>
            &lt;?=$this->graph->render()?&gt;
        </div>
</div>


<div id='postpaid_info'>
<h3>Postpaid Account Info</h3>
<ul>
    <li><label>Account Created</label>&lt;?=$postpaid['created']?&gt;</li>
    <li><label>Used</label>&lt;?=$postpaid['used']?&gt;</li>
</ul>
</div>


&lt;? $this->load->view('footer'); ?&gt;

To find out of how to use OpenFlashChart in detail explanation, visit http://teethgrinder.co.uk/open-flash-chart/ .

cheers
-Rafeequl


Messages In This Thread
OpenFlashChart with CI - by El Forum - 03-11-2008, 07:20 AM
OpenFlashChart with CI - by El Forum - 03-13-2008, 08:08 PM
OpenFlashChart with CI - by El Forum - 03-14-2008, 12:18 AM
OpenFlashChart with CI - by El Forum - 03-14-2008, 12:38 AM
OpenFlashChart with CI - by El Forum - 03-14-2008, 08:05 AM
OpenFlashChart with CI - by El Forum - 03-14-2008, 09:29 AM
OpenFlashChart with CI - by El Forum - 03-14-2008, 12:05 PM
OpenFlashChart with CI - by El Forum - 03-14-2008, 02:48 PM
OpenFlashChart with CI - by El Forum - 05-06-2008, 11:19 PM
OpenFlashChart with CI - by El Forum - 05-24-2008, 02:13 AM
OpenFlashChart with CI - by El Forum - 11-10-2008, 12:59 PM
OpenFlashChart with CI - by El Forum - 11-11-2008, 07:46 PM
OpenFlashChart with CI - by El Forum - 11-12-2008, 05:36 AM
OpenFlashChart with CI - by El Forum - 11-12-2008, 05:51 AM
OpenFlashChart with CI - by El Forum - 11-12-2008, 06:40 AM
OpenFlashChart with CI - by El Forum - 11-12-2008, 07:58 AM
OpenFlashChart with CI - by El Forum - 11-12-2008, 08:35 AM
OpenFlashChart with CI - by El Forum - 11-12-2008, 08:36 AM
OpenFlashChart with CI - by El Forum - 11-14-2008, 12:26 AM
OpenFlashChart with CI - by El Forum - 11-14-2008, 12:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB