Yii 1.1: yiiopenflashchart

Yii Open Flash Chart 2 Extension
17 followers

With this extension you can easy generate beauty charts on pages of your Yii application.

If you want, you can get a newest version of this extension using this command:

bash$ svn checkout http://yiiopenflashchart.googlecode.com/svn/trunk/ yiiopenflashchart

Or, of course, you can download it from Download section here

Resources

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/extensions

Usage

In the view file, where do you want shows an chart add the following code example:

// Creating an Yii Extension component
$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
// Minimum usage. You will always need at least this.
$flashChart->begin();
$flashChart->setData(array(1,2,2,3,5,6,1,9,6,4,5,6,7,8,0,8,2,2,1,9));
$flashChart->renderData('line');
$flashChart->render(300, 200);

More examples

Minimum with 2 datasets

$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
$flashChart->begin();
$flashChart->setData(array(1,2,4,8),'{n}',false,'Apples');
$flashChart->setData(array(3,4,6,9),'{n}',false,'Oranges');
$flashChart->renderData('line',array('colour'=>'green'),'Apples');
$flashChart->renderData('line',array('colour'=>'orange'),'Oranges');
$flashChart->render(300,200);

Minimum with 2 seperate charts

$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
$flashChart->begin();
$flashChart->setData(array(3,4,6,9),'{n}',false,'Potatoes');
$flashChart->setTitle('Veggies');
$flashChart->renderData('line',array('colour'=>'#cc3355'),'Potatoes');
$flashChart->render();
 
$flashChart->setTitle('Fruits');
$flashChart->setData(array(1,2,4,8),'{n}',false,'Apples','dig');
$flashChart->setData(array(3,4,6,9),'{n}',false,'Oranges','dig');
$flashChart->renderData('line',array('colour'=>'#33cc33'),'Apples','dig');
$flashChart->renderData('line',array('colour'=>'#ccaa44'),'Oranges','dig');
$flashChart->render(500,500,'dig');

Customizing your chart and setting labels

$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
$flashChart->begin('SteppChart');
$flashChart->setTitle('Steppometer','{color:#880a88;font-size:15px;padding-bottom:20px;}');
 
$data['1']['Day']['date'] = 'October \'09';
$data['1']['Day']['count'] = '123';
$data['2']['Day']['date'] = 'November \'09';
$data['2']['Day']['count'] = 345;
$data['3']['Day']['date'] = 'December \'09';
$data['3']['Day']['count'] = 500;
 
$flashChart->setData($data);
$flashChart->setNumbersPath('{n}.Day.count');
$flashChart->setLabelsPath('default.{n}.Day.date');
 
$flashChart->setLegend('x','Dato');
$flashChart->setLegend('y','Skritt', '{color:#AA0aFF;font-size:12px;}');
 
$flashChart->axis('x',array('tick_height' => 10,'3d' => -10));
$flashChart->axis('y',array('range' => array(0,600,100)));
 
$flashChart->renderData();
$flashChart->render(400,300);

Scatter

$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
$data = array();
for( $i=0; $i<360; $i+=5 )
{
    $data[] = array(
        'x' => number_format(sin(deg2rad($i)), 2, '.', ''),
        'y' => number_format(cos(deg2rad($i)), 2, '.', '')
    );
}
 
$flashChart->begin();
$flashChart->setData($data);
$flashChart->setTitle('Scatter');
$flashChart->axis('x',array('range' => array(-2,3,1)));
$flashChart->axis('y',array('range' => array(-2,2,1)));
$flashChart->renderData('scatter');
$flashChart->render(300,300);

Radar

$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
$flashChart->begin('progress');
$flashChart->setTitle('Radar');
$flashChart->setData(array(3, 4, 5, 4, 3, 3, 2.5));
$flashChart->setRadarAxis(array(
    'max' => 5,
    'steps' => 1,
    'colour' => '#EFD1EF',
    'grid_colour' => '#EFD1EF',
    'label_colour' => '#343434',
    'labels' => array('0', '1', '2', '3', '4', '5')));
$flashChart->setToolTip(null, array('proximity' => true));
$flashChart->renderData('radar', array(
    'halo_size' => 1,
    'width' => 1,
    'dot_size' => 2,
    'colour' => '#45909F',
    'type' => 'filled',
    'fill_colour' => '#45909F',
    'fill_alpha' => 0.4,
    'loop' => true)
);
$flashChart->render(300,300);

Stacked Bars, multiple charts and dom id

$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
$flashChart->begin();
$flashChart->setTitle('Stacked Bars');
$flashChart->axis('y',array('range' => array(0, 100, 10)));
$flashChart->setStackColours(array('#0000ff','#ff0000','#00FF00'));
$flashChart->setData(array(
    array(65,15,20),
    array(45,15,40),
    array(51,29,20),
    array(15,35,50),
));
$flashChart->renderData('bar_stack');
$flashChart->render(300,300);
$flashChart->setData(array(1,3,2,4),'{n}',false,'stuff','chart2');
$flashChart->renderData('line',array(),'stuff','chart2');
$flashChart->render(400,400,'chart2','chartDomId');
echo '<div id="chartDomId"></div>';

SKETCH - my favourite :)

$flashChart = Yii::createComponent('application.extensions.openflashchart2.EOFC2');
 
$flashChart->begin('Sketch Chart');
$flashChart->setTitle('Sketchometer','{color:#880a88;font-size:15px;padding-bottom:20px;}');
 
$data['1']['Day']['date'] = 'Oct \'09';
$data['1']['Day']['count'] = '321';
$data['2']['Day']['date'] = 'Nov \'09';
$data['2']['Day']['count'] = 345;
$data['3']['Day']['date'] = 'Dec \'09';
$data['3']['Day']['count'] = 500;
 
$flashChart->setData($data);
$flashChart->setNumbersPath('{n}.Day.count');
$flashChart->setLabelsPath('default.{n}.Day.date');
 
$flashChart->setLegend('x','Dato');
$flashChart->setLegend('y','Skritt', '{color:#AA0aFF;font-size:12px;}');
 
$flashChart->axis('x',array('tick_height' => 10,'3d' => -10));
$flashChart->axis('y',array('range' => array(0,600,100)));
 
$flashChart->renderData('sketch', array(
    'colour' => '#81AC00',
    'outline-colour' => '#567300',
    'offset' => 5,
    'fun_factor' => 7,
));
$flashChart->render(200,300);

All of above examples you can find in downloaded package in examples.txt file.

Change Log

January 8, 2009

Fixed issue with new PHP version, also added code for removing whitespaces from JS-output.

June 10, 2009

  • File downloading from yiiframework.com corrupted, changed description message.

May 5, 2009

  • Initial release.

Total 6 comments

#11352 report it
hemc at 2013/01/08 04:51am
getting error while running example "SKETCH - my favourite :)"

Non-static method Set::extract() should not be called statically, assuming $this from incompatible context any help please

#11116 report it
basem at 2012/12/18 07:06am
demo link is broken

demo link is broken

#5408 report it
Tyr84 at 2011/10/10 07:48am
Pie chart

Hello, is there possible for draw pie-chart? I guess not. Tnx

#3740 report it
lgzxz999 at 2011/05/04 03:08am
看着挺好,用着真烂

弄了半天还是不能让Y轴随着值自己设置范围

#2496 report it
Trejder at 2011/01/10 09:05am
Some other issues...

A few issues I found, when trying to use this extension:

  1. Correction: Only Total Commander wasn't able to extract downloaded .bz2 file (non-standard archive). I was able to extract it with 7-Zip and then TC was able to extract included yiiopenflashchart2-1.2.tar file.

  2. This extension is build upon php-ofc-library while newer php5-ofc-library ships with newest versions of Open Flash Charts 2.

  3. Extension author removed all read-me / licensee files from original code, he's using - for example readme.txt file for swfobject.js that is used by OFC / this extension. Not a good manner, to be honest. Files like this should be kept intact to inform others about licensee issues and to properly credit original work authors.

  4. This extensions seems to be not working, when chart generation is inside result of AJAX request. I tired the basic example and when I put it into my view, everything worked as excepted. But when I inserted it into view used in AJAX response generation process, all I got was a div generated by extension with unique ID set, but no chart at all. Maybe Chart generation JavaScripts conflicts somehow with AJAX request JS or I'm makings some mistake, but for right now result is that this extension can be easily used in normal view but somehow can't be used in AJAX request result.

  5. Discussion / forum link should be updated - right now it redirects to main forum page.

#1597 report it
jonah at 2009/06/09 06:32pm
error

when I try to extract the files it says it is corrupt. Re-upload?

Leave a comment

Please to leave your comment.

Create extension