|
|
Chart Elements - X Axis Labels 3
Object: x_axis_label( $text, $colour, $size, $rotate )
Parameters
- $text
Label text
- $colour
HTML Hex colour.
- $size
Font size in pixels
- $rotate
String can be one of "vertical" "diaganol" or "horizontal"
Methods:
- set_text( $text )
- set_colour( $colour )
- set_size( $size )
- set_rotate( $rotate )
- set_vertical()
- set_visible()
This overrides any previous attempt to make this label invisible. The parent
object (x_axis_labels) has a 'steps' attribute that makes some labels invisible,
use this to make them visible again.
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' );
$line_dot = new line_dot(); $line_dot->set_values( array(9,8,7,6,5,4,3,2,1) );
$chart = new open_flash_chart(); $chart->set_title( $title ); $chart->add_element( $line_dot );
// // 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, 'vertical'); // invisible $tmp[] = new x_axis_label('seven', '#0000FF', 30, 'vertical'); // visible $eight = new x_axis_label('eight', '#8C773E', 16, 'diagonal'); // would be invisible, but: $eight->set_visible(); // <-- FORCE this label visible $tmp[] = $eight; $tmp[] = new x_axis_label('nine', '#2683CF', 16, 'horizontal'); // 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:
|
|