Last updated September 17, 2009. Created by kong on April 3, 2009.
Edited by CKIDOW, cbow. Log in to edit this page.
- Download and install Open Flash Chart 2 API module
- Download the latest Open Flash Chart 2 package from http://teethgrinder.co.uk/open-flash-chart-2/downloads.php
-
Extract the package, put the
open-flash-chart.swffile 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
|-- ... -
If you want to use an external library e.g. the one that comes with Open Flash Chart 2 package, copy the
php-ofc-librarydirectory 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
|-- ...
|-- ... -
Configure Open Flash Chart 2 API by going to
/admin/settings/ofc_api - 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_chartThis worked for me:
<?phpprint open_flash_chart_api_render();
?>