Warning this is an old version.

Take me to the latest version

Chart Elements - X Axis Labels 2

Object: x_axis_labels

Methods:

  • set_steps( $steps )
    Show every $steps label.
  • set_labels( $labels )
    An array of [x_axis_label objects or strings] you can use both x_axis_label objects and strings in the same array.
  • set_colour( $colour )
    Colour as a HTML Hex colour.
  • set_size( $size )
    Font size in pixels.
  • set_vertical()
    Make all the labels vertical.

All these settings can be overridden in the x_axis_label object.

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-2.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-2.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_colour'#428C3E' );
$x->set_grid_colour'#86BF83' );

//
// Style the X Axis Labels:
//
$x_labels = new x_axis_labels();

// show every other label:
$x_labels->set_steps);

// set them vertical
$x_labels->set_vertical();

// make them red/pink-ish
$x_labels->set_colour'#CF4D5F' );

// nice big font
$x_labels->set_size16 );

// set the label text
$x_labels->set_labels(
    array( 
'one','two','three','four','five','six','seven','eight','nine' )
    );

//
// 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();
To see the data produced : gallery/x-axis-labels-2.php, then 'view source'.
Support This Project
Adverts:


Open Flash Chart logo by numb.me.uk. | Syntax highlights are by GeSHi