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.
error
when I try to extract the files it says it is corrupt. Re-upload?
Some other issues...
A few issues I found, when trying to use this extension:
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.
This extension is build upon php-ofc-library while newer php5-ofc-library ships with newest versions of Open Flash Charts 2.
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.
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.
Discussion / forum link should be updated - right now it redirects to main forum page.
看着挺好,用着真烂
弄了半天还是不能让Y轴随着值自己设置范围
Pie chart
Hello, is there possible for draw pie-chart? I guess not.
Tnx
demo link is broken
demo link is broken
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
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.