Open Flash Chart
Support This Project :: Home - Gallery - Bar Chart 2
Info: Open Flash Chart 2 is out. Version 1.x and these pages will never disappear and the charts will continue working forever, but further development on 1.x has stopped. Take a look at version 2 here Open Flash Chart 2.

Gallery - Bar Chart 2

Add different data to the graph.

In this chart we create 3 bar objects and fill each with bars. Then we add all 3 to the chart and display them.

Create the flash object
<?php
include_once 'ofc-library/open_flash_chart_object.php';
open_flash_chart_object500300'http://'$_SERVER['SERVER_NAME'] .'/open-flash-chart/gallery-data-15.php' );
?>
gallery-data-15.php
<?php

include_once( 'ofc-library/open-flash-chart.php' );

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

//
// We are diplaying 3 bar charts, so create 3
// bar chart objects:
//

$bar_1 = new bar50'#0066CC' );
$bar_1->key'Me'10 );

$bar_2 = new bar50'#9933CC' );
$bar_2->key'You'10 );

$bar_3 = new bar50'#639F45' );
$bar_3->key'Them'10 );

//
// NOTE: how we are filling 3 arrays full of data,
//       one for each bar on the graph
//
for( $i=0$i<9$i++ )
{
  
$bar_1->data[] = rand(2,5);
  
$bar_2->data[] = rand(5,9);
  
$bar_3->data[] = rand(2,9);
}

// create the chart:
$g = new graph();
$g->title'Bar Chart''{font-size: 26px;}' );

// add the 3 bar charts to it:
$g->data_sets[] = $bar_1;
$g->data_sets[] = $bar_2;
$g->data_sets[] = $bar_3;


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

$g->set_y_max10 );
$g->y_label_steps);
$g->set_y_legend'Open Flash Chart'12'0x736AFF' );
echo 
$g->render();
?>
To see the data produced : gallery-data-15.php, then 'view source'.
Help support the project: Support This Project

Adverts: