Chart Elements - Y Axis

Object: y_axis

Methods:

  • set_stroke( $s )
    Line width in pixels
  • set_tick_length( $val )
  • set_colours( $colour, $grid_colour )
  • set_colour( $colour )
  • set_grid_colour( $colour )
  • set_range( $min, $max, $steps=1 )
    Set min and max values, also (optionally) set the steps value.
  • set_offset( $off )
    $off: Boolean. If true the Y axis is nudged up half a step.
  • set_labels( $labels )
    An array of string values. By default the Y axis will show from min to max, but you can override this by passing in your own labels. Remember the Y axis min is at the bottom, so the labels will go from bottom to top.
  • set_steps( $steps )
    Only show every $steps label

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/y-axis.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/y-axis.php
<?php

include '../php-ofc-library/open-flash-chart.php';

$title = new titledate("D M d Y") );

$line_dot = new line_dot();
$line_dot->set_values( array(4,5,6,7,6,5,4,3,2) );

$chart = new open_flash_chart();
$chart->set_title$title );
$chart->add_element$line_dot );

//
// create an X Axis object
//
$y = new y_axis();
$y->set_stroke10 );
$y->set_colour'#D7E4A3' );
$y->set_tick_length30 );
$y->set_grid_colour'#A2ACBA' );
$y->set_steps);
$y->set_labels( array('Zero','One','Two','Three','Four','Five','Six','Seven','Eight') );

//
// Add the Y Axis object to the chart:
//
$chart->set_y_axis$y );

echo 
$chart->toPrettyString();
To see the data produced : gallery/y-axis.php, then 'view source'.
Support This Project

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