Charts - Pie Charts - Advanced Pie Chart
See pie charts for details on the objects used in
this example. For more examples see advanced pie chart 2.
Note: The pie chart will auto size its self so all the labels fit onto the
screen. So if you have two or three charts on one page they will be different sizes
because your labels will be in different positions.
This goes into the <head> of the page:
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF(
"open-flash-chart.swf", "my_chart",
"300", "300", "9.0.0", "expressInstall.swf",
{"data-file":"gallery/adv-pie-chart.php"} );
</script>
This writes the chart into a div with id="my_chart",
right click and view source to see it in action,
[the tutorials have more details]
gallery/adv-pie-chart.php
<?php
include '../php-ofc-library/open-flash-chart.php';
$title = new title( 'Pork Pie, Mmmmm' );
$d = array(); $d[] = 2; // <-- blue $d[] = 3; // <-- grey $d[] = 4; // <-- green $tmp = new pie_value(6.5, ""); // // this slice would normally be light green // but we are overriding the colour here: // $tmp->set_colour( '#FF33C9' ); $tmp->set_label('BIG', '#FF653F', 24 ); $d[] = $tmp; // // here the colour cycle wraps and this gets the // first colour: // $d[] = new pie_value(6.5, "6.5"); // <-- blue $d[] = 3; // <-- grey $d[] = 4; // <-- green $d[] = 2; // <-- light green
$pie = new pie(); $pie->set_start_angle( 35 ); $pie->set_animate( true ); $pie->set_label_colour( '#432BAF' ); $pie->set_gradient_fill(); $pie->set_tooltip( '#val# of #total#<br>#percent# of 100%' ); $pie->set_colours( array( '#1F8FA1', // <-- blue '#848484', // <-- grey '#CACFBE', // <-- green '#DEF799' // <-- light green ) );
$pie->set_values( $d );
$chart = new open_flash_chart(); $chart->set_title( $title ); $chart->add_element( $pie );
echo $chart->toPrettyString();
|
Adverts:
|