Open Flash Chart
Support This Project :: Home - Gallery - Format Numbers
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 - Format Numbers

Method: set_y_format

set_y_format( string $val )

Format the Y axis labels. If any of the following format options are used, the Y axis labels use the format options.

In the string, the magic #val# is replaced with the actual value (see tooltip for more details on magic string values). So in the example above the following Y Axis Format string was used:

#val# km

So #val# is replaced with the calculated Y Axis value.

Method: set_num_decimals

set_num_decimals( integer $val )

For example, we set this to 3, so now 6.6666666666 becomes 6.666 and 7.1 stays as 7.1

This effects the tooltips, the Y axis labels and the X axis labels in scatter charts.

Method: set_is_fixed_num_decimals_forced

set_is_fixed_num_decimals_forced( boolean $val )

If this is set to true the chart will display all calculated numbers with set_num_decimals() (see above) (e.g. for set_num_decimals(3), 10 becomes 10.000, 10.1 becomes 10.100) this is useful for prices: £10 becomes £10.00

This effects the tooltips, the Y axis labels and the X axis labels in scatter charts.

Method: set_is_decimal_separator_comma

set_is_decimal_separator_comma( boolean $val )

Use a comma for the decimal seperator.

This effects the tooltips, the Y axis labels and the X axis labels in scatter charts.

Method: set_is_thousand_separator_disabled

set_is_thousand_separator_disabled( boolean $val )

Stop using a comma to seperate the thousands.

This effects the tooltips, the Y axis labels and the X axis labels in scatter charts.

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

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

//
// NOTE: how we are filling 3 arrays full of data,
//       one for each bar on the graph
//
$data_1 = array();
for( 
$i=0$i<10$i++ )
{
  
$data_1[] = rand(50000,60000) + 0.666666666666;
}

include_once( 
'ofc-library/open-flash-chart.php' );
$g = new graph();
$g->title'Sketch''{font-size:20px; color: #ffffff; margin:10px; background-color: #d070ac; padding: 5px 15px 5px 15px;}' );
$g->bg_colour '#FDFDFD';

$g->set_data$data_1 );
$g->bar_sketch556'#d070ac''#000000''2006'10 );


$g->x_axis_colour'#e0e0e0''#e0e0e0' );
$g->set_x_tick_size);
$g->y_axis_colour'#e0e0e0''#e0e0e0' );

$g->set_x_labels( array( 'January','February','March','April','May','June','July','August','September','October' ) );
$g->set_x_label_style11'#303030');
$g->set_y_label_style11'#303030');

$g->set_y_min40000 );
$g->set_y_max70000 );
$g->y_label_steps);

$g->set_y_format'#val# km' );
$g->set_num_decimals);
$g->set_is_fixed_num_decimals_forcedtrue );
$g->set_is_decimal_separator_commatrue );
$g->set_is_thousand_separator_disabledtrue );  

echo 
$g->render();
?>
To see the data produced : gallery-data-47.php, then 'view source'.
Help support the project: Support This Project

Adverts: