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

pie()

pie( integer $alpha, string $line_colour, string $style )
$alpha (0-100) is the alpha of the chart. As you mouse over each slice it will fade from $alpha to 100.
$line_colour is the HEX colour of the outline.
$style is the CSS style string of the labels. Use {display: none;} to remove the labels, the label values are still displayed in the tooltips (see pie links for an example).

pie_values()

pie_values( array $values, array $labels )
$values is an array of integers.
$labels is an array of strings, that label each slice.
The $values will be shown as percentages as this is the traditional way of displaying pie charts. The whole chart represents 100%, and each slice is part of that.

pie_slice_colours()

pie_slice_colours( array $colours )
$colours is an array of string HEX colours. If there are more values than colours in this array, the colours will be re-used. E.g:

$g->pie_values(
  array(10,20,20,10,5),
  array('IE','Firefox','Opera','Wii','Other') );

$g->pie_slice_colours( array('#FF0000','#00FF00','#0000FF') );
This sets IE to red (#FF0000), Firefox to green (#00FF00) and Opera to blue (#0000FF), because we have run out of colours Wii is set to red (#FF0000) and Other is set to green (#00FF00).

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

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

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

include_once( 
'ofc-library/open-flash-chart.php' );
$g = new graph();

//
// PIE chart, 60% alpha
//
$g->pie(60,'#505050','{font-size: 12px; color: #404040;');
//
// pass in two arrays, one of data, the other data labels
//
$g->pie_values$data, array('IE','Firefox','Opera','Wii','Other') );
//
// Colours for each slice, in this case some of the colours
// will be re-used (3 colurs for 5 slices means the last two
// slices will have colours colour[0] and colour[1]):
//
$g->pie_slice_colours( array('#d01f3c','#356aa0','#C79810') );

$g->set_tool_tip'#val#%' );

$g->title'Pie Chart''{font-size:18px; color: #d01f3c}' );
echo 
$g->render();
?>
To see the data produced : gallery-data-27.php, then 'view source'.
Help support the project: Support This Project

Adverts: