You are here

Open Flash Chart API

Drupal Modules - Sat, 17/11/2007 - 12:22am

This project allows a user/developer to add a flash chart to anywhere they can put php.

Code Example

<?php
// generate some random data
srand((double)microtime()*1000000);


$data = array();
for( $i=0; $i<6; $i++ )
{
  $data[] = rand(5,9);
}

$g = new open_flash_chart_graph();
$g->title( 'Bar Chart', '{font-size: 20px;}' );
$g->set_width(200);

//
// BAR CHART:
//
$g->set_data( $data );
$g->bar( 50, '#9933CC', '#8010A0', 'Page views', 10 );
//
// ------------------------
//

//
// X axis tweeks:
//
$g->set_x_labels( array( 'January,February,March,April,May,June' ) );
//
// set the X axis to show every 2nd label:
//
$g->set_x_label_style( 10, '#9933CC', 0, 2 );
//
// and tick every second value:
//
$g->set_x_axis_steps( 2 );
//

$g->set_y_max( 10 );
$g->y_label_steps( 4 );
$g->set_y_legend( 'Open Flash Chart', 12, '#736AFF' );
$g->set_bg_colour('0xDFFFDF');
echo $g->render('js');
?>

Steps for installation
  1. Download and install this module.
  2. Download the package from http://www.teethgrinder.co.uk/open-flash-chart
  3. Unzip the package
  4. Copy the js folder and open-flash-chart.swf to the module folder.