Chart Elements - X Axis Menu - X Axis Labels 3
We use steps to make some lables visible. We also override this in some of the lables.
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/x-axis-labels-3.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/x-axis-labels-3.php
<?php
include '../php-ofc-library/open-flash-chart.php';
$title = new title( 'X Axis Labels Complex Example' );
$hol = new hollow_dot(); $hol->size(3)->halo_size(1)->tooltip('#x_label#<br>#val#');
$line = new line(); $line->set_default_dot_style($hol); $line->set_values( array(5,5,5,5,5,6,5,5,4,6) );
$chart = new open_flash_chart(); $chart->set_title( $title ); $chart->add_element( $line );
// // create an X Axis object // $x = new x_axis(); $x->set_stroke( 1 ); $x->set_colour( '#428C3E' ); $x->set_tick_height( 5 ); $x->set_grid_colour( '#86BF83' ); // // here we place a tick on every X location: // $x->set_steps( 1 );
$x_labels = new x_axis_labels(); // // show every other label // $x_labels->set_steps( 2 ); $x_labels->set_vertical(); $x_labels->set_colour( '#ff0000' ); $x_labels->set_size( 16 );
$tmp = array(); // // these labels will inherit thier properties from $x_labels // including 'visible' from the 'steps' value (which, for // this example is 2) I have noted the inherited visible // status for each item: // $tmp[] = 'one'; // visible $tmp[] = 'two'; // invisible $tmp[] = 'three'; // visible $tmp[] = 'four'; // invisible $tmp[] = 'five'; // visible // // these will override some or all of the // inherited properties // $tmp[] = new x_axis_label('six', '#0000FF', 30, 270); // invisible $tmp[] = new x_axis_label('seven', '#0000FF', 30, 270); // visible $eight = new x_axis_label('eight', '#8C773E', 16, 315); // would be invisible, but: $eight->set_visible(); // <-- FORCE this label visible $tmp[] = $eight; $tmp[] = new x_axis_label('nine', '#2683CF', 16, 0); // visible
// // add the labels to the X Axis Labels object // $x_labels->set_labels( $tmp );
// // Add the X Axis Labels to the X Axis // $x->set_labels( $x_labels );
// // Add the X Axis object to the chart: // $chart->set_x_axis( $x );
echo $chart->toPrettyString();
|
Adverts:
|