Open Flash Chart
Support This Project :: Home - Gallery - Bar + Line Chart
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 + Line Chart

Mix bars and lines on one chart.

It is easy to mix bar and lines on one graph. To display a set of data as a line, call the line() method. To display a set of data as a bar call the bar() method.

The order in which you call these methods determins which is on top, Open Flash Chart will display the first set of data (either a line or bar), then display the next data set on top of the first.

The order in which you pass the sets of data to Open Flash Chart also effects the order they are displayed in the key.

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

// generate some random data

// NOTE: how we are filling 3 arrays full of data,
//       one for each line on the graph
$data_1 = array();
$data_2 = array();
$data_3 = array();
$i=0$i<9$i++ )
$data_1[] = rand(2,5);
$data_2[] = rand(4,7);
$data_3[] = rand(5,9);

'ofc-library/open-flash-chart.php' );
$g = new graph();
$g->title'Mixed Line and Bar Charts''{font-size: 35px; color: #800000}' );

$g->set_data$data_1 );
$g->bar50'#9933CC''Purple Bar'10 );

$g->set_data$data_2 );
$g->bar50'#339966''Green Bar'10 );

$g->set_data$data_3 );
$g->line_dot35'#CC3399''Line'10 );    // <-- 3px thick + dots

$g->set_x_labels( array( 'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep' ) );
$g->set_y_max10 );
$g->set_y_legend'Your legend here!'12'#736AFF' );
To see the data produced : gallery-data-16.php, then 'view source'.
Help support the project: Support This Project