Community Documentation

Installation

Last updated September 17, 2009. Created by kong on April 3, 2009.
Edited by CKIDOW, cbow. Log in to edit this page.

  1. Download and install Open Flash Chart 2 API module
  2. Download the latest Open Flash Chart 2 package from http://teethgrinder.co.uk/open-flash-chart-2/downloads.php
  3. Extract the package, put the open-flash-chart.swf file in the module's directory. The directory layout should look like this:

    ofc_api
        |-- ofc_api.info
        |-- ofc_api.module
        |-- swfobject.js
        |-- open-flash-chart.swf
        |-- ...
  4. If you want to use an external library e.g. the one that comes with Open Flash Chart 2 package, copy the php-ofc-library directory into the module's directory as well. The resulting directory layout should look like this:

    ofc_api
        |-- ofc_api.info
        |-- ofc_api.module
        |-- swfobject.js
        |-- open-flash-chart.swf
        |-- php-ofc-library
            |-- open-flash-chart.php
            |-- ...
        |-- ...
  5. Configure Open Flash Chart 2 API by going to /admin/settings/ofc_api

  6. You can verify the installation by creating a new Page or Story, set input format to PHP code and put the following code in the body:

    <?php
       
    print ofc_api_render();
    ?>

    Click the "Preview" button, if the sample chart shows up then you're good to go :)

Comments

sample code above is wrong but this is working

put this in your node to test:

<?php
//just the out of the box example
print open_flash_chart_api_render();

//now I'll try my own small variation, you can make your own graph with the code below:

  // create new chart object
 
$chart = ofc_api_chart();

 
// set chart title
 
$title = "Open Flash Chart 2 API\nSample Chart";
  if ( !
is_null($callback_params) ) {

   
$title .= "\nARG1=" . $callback_params[1];
  }
 
$chart->set('title', array(
   
'text' => $title,
   
'style' => '{font-size: 12px; font-family: Verdana, Arial, sans-serif; text-align: center;}',
  ));

 
// create new bar_sketch element and set its attributes
 
$bar = ofc_api_element('bar_sketch');
 
$bar->set('colour', '#81ac00');
 
$bar->set('outline-colour', '#567300');
 
$bar->set('offset', 7);
 
$bar->set('values', array(5, 1, 4, 3, 2, 26));
 
$bar->set('tip', 'Value: #val#');

 
// add bar_sketch element to the chart
 
$chart->add('element', $bar);



print
open_flash_chart_api_render($chart);
?>

It seems the API has changed

It seems the API has changed as there is no longer a function called ofc_api_chart

This worked for me:

<?php
print open_flash_chart_api_render();
?>

About this page

Drupal version
Drupal 6.x
Audience
Developers and coders, Themers

Develop for Drupal

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.