How to implement Open Flash Chart 2 on Symfony

972 views Asked by At

I'm trying to use Open Flash Chart 2 on my symfony project by including the ofc2 library on one of my controller's action.

Unfortunately it doesn't work. When i call the action it prints nothing :'(

There is a plugin for this, but it uses an outdated version of OFC.

Anyone have had any success showing Open Flash Chart 2 on their site?

Here's how my controller's actions file looks:

<?php

class chartActions extends sfActions{

    public function executeTestChartData(sfWebRequest $request){
        $this->getResponse()->setHttpHeader('Content-Type','text/plain');

        include('/cidat/lib/php-ofc-library/open-flash-chart.php');

        $title = new title( date("D M d Y") );

        $bar = new bar();
        $bar->set_values( array(9,8,7,6,5,4,3,2,1) );

        $chart = new open_flash_chart();
        $chart->set_title( $title );
        $chart->add_element( $bar );

        $output = $chart->toPrettyString();

        return $this->renderText($output);
    }
}

?>

Thanks in advance,

Vic

1

There are 1 answers

1
victmo On

Ok, I finally solved it. Here's what I did:

  1. Copied open-flash-chart.php to /lib/php-ofc-library
  2. Copied the rest of the files included in the OFC2 php lib to /apps/my-app/lib directory
  3. Last, removed include('/lib/php-ofc-library/open-flash-chart.php'); from my controller's action.

That's it. Don't forget to clear cache.

Cheers