[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/ezc/Graph/src/axis/ -> numeric.php (summary)

File containing the abstract ezcGraphChartElementNumericAxis class

Copyright: Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
License: http://ez.no/licenses/new_bsd New BSD License
Version: 1.5
File Size: 505 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ezcGraphChartElementNumericAxis:: (14 methods):
  __construct()
  __set()
  getNiceNumber()
  calculateMinimum()
  calculateMaximum()
  calculateMinorStep()
  calculateMajorStep()
  addData()
  calculateAxisBoundings()
  getCoordinate()
  getMinorStepCount()
  getMajorStepCount()
  getLabel()
  isZeroStep()


Class: ezcGraphChartElementNumericAxis  - X-Ref

Class to represent a numeric axis.

Axis elements represent the axis in a bar, line or radar chart. They are
chart elements (ezcGraphChartElement) extending from
ezcGraphChartElementAxis, where additional formatting options can be found.
You should generally use the axis, which matches your input data best, so
that the automatic chart layouting works best. Aavailable axis types are:

- ezcGraphChartElementDateAxis
- ezcGraphChartElementLabeledAxis
- ezcGraphChartElementLogarithmicalAxis
- ezcGraphChartElementNumericAxis

The axis tries to calculate "nice" start and end values for the axis scale.
The used interval is considered as nice, if it is equal to [1,2,5] * 10^x
with x in [.., -1, 0, 1, ..].

The start and end value are the next bigger / smaller multiple of the
intervall compared to the maximum / minimum axis value.

You may specify custom step sizes using the properties $majorStep and
$minorStep. The minimum and maximum values for the axis labels can be
defined using the $min and $max properties. You should be able to set any
subset of these values, and all values not explicitely set will be
calculated automatically.

This axis should be used for all numeric values except dates. If your data
does span very big number intervals you might want to consider using the
logrithmic axis instead.

The numeric axis may be used like:

<code>
$graph = new ezcGraphLineChart();
$graph->title = 'Some random data';
$graph->legend = false;

$graph->xAxis = new ezcGraphChartElementNumericAxis();
// The y axis is numeric by default.

$graph->xAxis->min = -15;
$graph->xAxis->max = 15;
$graph->xAxis->majorStep = 5;

$data = array(
array(),
array()
);
for ( $i = -10; $i <= 10; $i++ )
{
$data[0][$i] = mt_rand( -23, 59 );
$data[1][$i] = mt_rand( -23, 59 );
}

// Add data
$graph->data['random blue'] = new ezcGraphArrayDataSet( $data[0] );
$graph->data['random green'] = new ezcGraphArrayDataSet( $data[1] );

$graph->render( 400, 150, 'tutorial_axis_numeric.svg' );
</code>

__construct( array $options = array()   X-Ref
Constructor

param: array $options Default option array
return: void

__set( $propertyName, $propertyValue )   X-Ref
__set

param: mixed $propertyName
param: mixed $propertyValue
return: void

getNiceNumber( $float )   X-Ref
Returns a "nice" number for a given floating point number.

Nice numbers are steps on a scale which are easily recognized by humans
like 0.5, 25, 1000 etc.

param: float $float Number to be altered
return: float Nice number

calculateMinimum( $min, $max )   X-Ref
Calculate minimum value for displayed axe basing on real minimum and
major step size

param: float $min Real data minimum
param: float $max Real data maximum
return: void

calculateMaximum( $min, $max )   X-Ref
Calculate maximum value for displayed axe basing on real maximum and
major step size

param: float $min Real data minimum
param: float $max Real data maximum
return: void

calculateMinorStep( $min, $max )   X-Ref
Calculate size of minor steps based on the size of the major step size

param: float $min Real data minimum
param: float $max Real data maximum
return: void

calculateMajorStep( $min, $max )   X-Ref
Calculate size of major step based on the span to be displayed and the
defined MIN_MAJOR_COUNT constant.

param: float $min Real data minimum
param: float $max Real data maximum
return: void

addData( array $values )   X-Ref
Add data for this axis

param: array $values Value which will be displayed on this axis
return: void

calculateAxisBoundings()   X-Ref
Calculate axis bounding values on base of the assigned values

return: void

getCoordinate( $value )   X-Ref
Get coordinate for a dedicated value on the chart

param: float $value Value to determine position for
return: float Position on chart

getMinorStepCount()   X-Ref
Return count of minor steps

return: integer Count of minor steps

getMajorStepCount()   X-Ref
Return count of major steps

return: integer Count of major steps

getLabel( $step )   X-Ref
Get label for a dedicated step on the axis

param: integer $step Number of step
return: string label

isZeroStep( $step )   X-Ref
Is zero step

Returns true if the given step is the one on the initial axis position

param: int $step Number of step
return: bool Status If given step is initial axis position



Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7