Md. Golam Rabbany

Just work with honesty, Success will come on your door

Monthly Archives: January 2008

Flash Chart Integrate With CodeIgniter


Requirements:
1. a swf file
2. a helper file
3. a library file
4. a controller

SWF File:
Download the file and past it root folder like http://localhost/your_folder

Helper File:
Download the helper file and past it root folder like http://localhost/your_folder/system/helpers

Library File:
Download the library file and past it root folder like http://localhost/your_folder/system/libraries

Controller File:

create a controller name Welcome and past the code:

<?php

class Welcome extends Controller {

function Welcome()
{
parent::Controller();
}

function index()
{

$this->load->helper(‘flash_chart’);
$this->load->helper(‘url’);
$base_url = site_url(‘Welcome/flash_data’);
open_flash_chart_object( 500, 250, $base_url, false );

}

function flash_data()

{

$this->load->library(‘graph’);
srand((double)microtime()*1000000);

$bar_red = new bar_3d( 75, ‘#D54C78’ );
$bar_red->key( ‘2006’, 10 );

// add random height bars:
for( $i=0; $i<10; $i++ )
$bar_red->data[] = rand(2,5);

//
// create a 2nd set of bars:
//
$bar_blue = new bar_3d( 75, ‘#3334AD’ );
$bar_blue->key( ‘2007’, 10 );

// add random height bars:
for( $i=0; $i<10; $i++ )
$bar_blue->data[] = rand(5,9);

// create the graph object:
$g = new graph();
$g->title( ‘3D Bar Chart’, ‘{font-size:20px; color: #FFFFFF; margin: 5px; background-color: #505050; padding:5px; padding-left: 20px; padding-right: 20px;}’ );

//$g->set_data( $data_1 );
//$g->bar_3D( 75, ‘#D54C78’, ‘2006’, 10 );

//$g->set_data( $data_2 );
//$g->bar_3D( 75, ‘#3334AD’, ‘2007’, 10 );

$g->data_sets[] = $bar_red;
$g->data_sets[] = $bar_blue;

$g->set_x_axis_3d( 12 );
$g->x_axis_colour( ‘#909090’, ‘#ADB5C7’ );
$g->y_axis_colour( ‘#909090’, ‘#ADB5C7’ );

$g->set_x_labels( array( ‘January,February,March,April,May,June,July,August,September,October’ ) );
$g->set_y_max( 10 );
$g->y_label_steps( 5 );
$g->set_y_legend( ‘Open Flash Chart’, 12, ‘#736AFF’ );
echo $g->render();

}

}
?>

Now run your graph : hrrp://loclahost/your_folder/ and out put like this
Grpah Image

if your want to know more about this graph please visit: http://http://teethgrinder.co.uk/open-flash-chart/

Advertisements