views:

232

answers:

1

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  A: 

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

victmo
If a PHP class has dependencies and they're not `include()`'ed properly in the class definitions, it's not your fault :)Glad you solved it.
Raise