Development

mwOpenFlashChartPlugin

You must first sign up to be able to contribute.

mwOpenFlashChart plugin

Flash chart generation using the LGPL Open Flash Chart Library.
This plug-in is an adaptation of the official OpenFlashChart PHP Classes.

Installation

Install the plugin using the following command:

$ php symfony plugin-install http://plugins.symfony-project.com/mwOpenFlashChart

Usage

Create two (or more) actions:

<?
class exampleActions extends sfActions {

    ...
    ...
    ...

    /*
     * This action should be used to create the view that will have
     * the charts. This view can have more than one chart at a time.
     */
    public function executeCharts() {
        ...
        ...
        ...
        return sfView::SUCCESS;
    }

    /*
     * This action should be used to retrieve chart data
     */
    public function executeChartData() {
        $response = $this->getResponse();
        $response->setContentType("text/plain");
        $response->addCacheControlHttpHeader('no-cache');

        // Data... :)
        for( $i=0; $i<5; $i++) {
             $data[] = rand(5,15);
        }        

        $graph = new OpenFlashChart();

        // PIE chart, 60% alpha
        $graph->pie(60,'#505050','{font-size: 12px; color: #404040;');

        // pass in two arrays, one of data, the other data labels
        $graph->pie_values( $data, array('IE','Firefox','Opera','Wii','Other') );

        // 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]):
        $graph->pie_slice_colours( array('#d01f3c','#356aa0','#C79810') );
    
        $graph->set_tool_tip( '#val#%' );
    
        $graph->title( 'Pie Chart', '{font-size:18px; color: #d01f3c}' );        
    
        return $this->renderText($graph->render());
    }
    
    ...
    ...
    ...
    
}
?>


Then, create the view template...

<? use_helper("OpenFlashChart"); ?>
...
...
...
<?= open_flash_chart( 300, 300, 'example/chartData'); ?>

...replacing "example" with your own module name.

That's it! :)

Attachments