Gallery - Advanced Floating Bars
Make a bar chart.
See bar chart for details on the bar object.
This example shows how to use the bar_value object and the null value.
Note how the tooltip magic value #val# is the height of the bar (top-bottom)
for all bars. Use #top# to get the top value and #bottom# to get the bottom
value, or just set the tip text to anything you want.
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",
"550", "400", "9.0.0", "expressInstall.swf",
{"data-file":"gallery/adv-floating-bars.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-floating-bars.php
<?php
include '../php-ofc-library/open-flash-chart.php';
$data_1 = array();
$data_1[] = 130; $data_1[] = new bar_value(150,130); $data_1[] = new bar_value(170,150); $data_1[] = new bar_value(190,170); $tmp = new bar_value(200,150); $tmp->set_colour( '#000000' ); $tmp->set_tooltip( 'Hello<br>#top#' ); $data_1[] = $tmp; $data_1[] = null; $data_1[] = 150;
$bar = new bar(); $bar->set_values( $data_1 );
$data_2 = array(); $data_2[] = 140; $data_2[] = new bar_filled_value(155,135); $data_2[] = new bar_filled_value(175,155); $data_2[] = new bar_filled_value(195,175); $tmp = new bar_filled_value(190,145); $tmp->set_colour( '#FF00FF' ); $tmp->set_outline_colour( '#900090' ); $tmp->set_tooltip( 'Custom tooltip<br>top:#top#<br>bottom:#bottom#<br>Value:#val#' ); $data_2[] = $tmp; $data_2[] = 160; $data_2[] = 130;
$bar_2 = new bar_filled(); $bar_2->set_values( $data_2 ); $bar_2->set_colour( '#FFEF3F' ); $bar_2->set_tooltip( 'top:#top#<br>bottom:#bottom#<br>Value:#val#' );
$y = new y_axis(); $y->set_range( 100, 200, 10 );
$chart = new open_flash_chart(); $chart->set_title( new title( date("D M d Y") ) ); $chart->add_element( $bar ); $chart->add_element( $bar_2 ); $chart->set_bg_colour( '#FFFFFF' ); $chart->set_y_axis( $y );
echo $chart->toPrettyString();
|
|