Open Flash Chart
Support This Project :: Home - Gallery - Y Axis Labels
Info: Open Flash Chart 2 is out. Version 1.x and these pages will never disappear and the charts will continue working forever, but further development on 1.x has stopped. Take a look at version 2 here Open Flash Chart 2.

Gallery - Y Axis Labels

Change the Y axis label steps, tick size and axis colour.

set_y_max( $max )
y_label_steps( $val )
$max integer, max value on Y axis.
$val integer, label every $val steps.

The chart elements will resize themselves to accomodate the Y axis labels.

Steps are the number of labels to show. So if set_y_max(20) and y_label_steps(5) then the chart will label the Y axis with 0,4,8,12,16,20. It is better to choose a round number for the Y max value, and set the steps so they are also calculated to be rounded numbers. This makes the chart easier for people to read.

So for example:

set_y_max(3) & y_label_steps(3) = 0,1,2,3
set_y_max(6) & y_label_steps(3) = 0,2,4,6
set_y_max(60) & y_label_steps(6) = 0,10,20,30,40,50,60

Another way to think of this is, 10/10 = label every 1, 10/5 = label every 2nd, 9/3 = label every 3rd.

The reason the steps are calculated in this way is a bit boring and technical. All it does is reduce the chance that through a small mistake you don't label every single value, from 0 to a million and crash the flash plug in (like I did a few times when developing Open Flash Chart.)


Create the flash object
<?php
include_once 'ofc-library/open_flash_chart_object.php';
open_flash_chart_object400250'http://'$_SERVER['SERVER_NAME'] .'/open-flash-chart/gallery-data-5.php' );
?>

gallery-data-5.php
<?php

// generate some random data
srand((double)microtime()*1000000);

$max 2000000;
$tmp = array();
$x_labels = array();
for( 
$i=0$i<9$i++ )
{
  
$tmp[] = rand(0,$max);
  
$x_labels[] = $i;
}

include_once( 
'ofc-library/open-flash-chart.php' );
$g = new graph();
$g->set_data$tmp );
$g->set_x_labels$x_labels );
$g->set_y_max2000000 );
$g->y_label_steps);
$g->title'Enter Shikari''{font-size: 20px; color: #000080}' );
echo 
$g->render();
?>
To see the data produced : gallery-data-5.php, then 'view source'.
none
Help support the project: Support This Project

Adverts: