Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcGraphChartElementNumericAxis

Graph::ezcGraphChartElementNumericAxis

Class ezcGraphChartElementNumericAxis

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:

  1.   $graph = new ezcGraphLineChart();
  2.   $graph->title = 'Some random data';
  3.   $graph->legend = false;
  4.  
  5.   $graph->xAxis = new ezcGraphChartElementNumericAxis();
  6.   // The y axis is numeric by default.
  7.  
  8.   $graph->xAxis->min = -15;
  9.   $graph->xAxis->max = 15;
  10.   $graph->xAxis->majorStep = 5;
  11.  
  12.   $data = array(
  13.       array(),
  14.       array()
  15.   );
  16.   for ( $i = -10; $i <= 10; $i++ )
  17.   {
  18.       $data[0][$i] = mt_rand( -23, 59 );
  19.       $data[1][$i] = mt_rand( -23, 59 );
  20.   }
  21.  
  22.   // Add data
  23.   $graph->data['random blue'] = new ezcGraphArrayDataSet( $data[0] );
  24.   $graph->data['random green'] = new ezcGraphArrayDataSet( $data[1] );
  25.  
  26.   $graph->render( 400, 150, 'tutorial_axis_numeric.svg' );

Source for this file: /Graph/src/axis/numeric.php

ezcBaseOptions
   |
   --ezcGraphChartElement
      |
      --ezcGraphChartElementAxis
         |
         --ezcGraphChartElementNumericAxis
Version:   //autogentag//

Constants

MIN_MAJOR_COUNT = 5 Constant used for calculation of automatic definition of major scaling

steps

MIN_MINOR_COUNT = 8 Constant used for automatic calculation of minor steps from given major

steps

Properties

mixed read/write $majorStep
Labeled major steps displayed on the axis.
float read/write $max
Maximum value of displayed scale on axis.
float read $maxValue
Maximum value to display on this axis.
float read/write $min
Minimum value of displayed scale on axis.
float read $minValue
Minimum Value to display on this axis.
mixed read/write $minorStep
Non labeled minor steps on the axis.

Inherited Member Variables

From ezcGraphChartElementAxis
protected ezcGraphChartElementAxis::$axisLabelRenderer
protected ezcGraphChartElementAxis::$innerBoundings
From ezcBaseOptions
protected ezcBaseOptions::$properties

Method Summary

public void addData( $values )
Add data for this axis
public abstract void calculateAxisBoundings( )
Calculate axis bounding values on base of the assigned values
protected void calculateMajorStep( $min , $max )
Calculate size of major step based on the span to be displayed and the defined MIN_MAJOR_COUNT constant.
protected void calculateMaximum( $min , $max )
Calculate maximum value for displayed axe basing on real maximum and major step size
protected void calculateMinimum( $min , $max )
Calculate minimum value for displayed axe basing on real minimum and major step size
protected void calculateMinorStep( $min , $max )
Calculate size of minor steps based on the size of the major step size
public float getCoordinate( $value )
Get coordinate for a dedicated value on the chart
public string getLabel( $step )
Get label for a dedicated step on the axis
public integer getMajorStepCount( )
Return count of major steps
public integer getMinorStepCount( )
Return count of minor steps
protected float getNiceNumber( $float )
Returns a "nice" number for a given floating point number.
public bool isZeroStep( $step )
Is zero step

Inherited Methods

From ezcGraphChartElementAxis
public abstract void ezcGraphChartElementAxis::addData()
Add data for this axis
public abstract void ezcGraphChartElementAxis::calculateAxisBoundings()
Calculate axis bounding values on base of the assigned values
public abstract float ezcGraphChartElementAxis::getCoordinate()
Get coordinate for a dedicated value on the chart
public abstract string ezcGraphChartElementAxis::getLabel()
Get label for a dedicated step on the axis
public abstract integer ezcGraphChartElementAxis::getMajorStepCount()
Return count of major steps
public abstract integer ezcGraphChartElementAxis::getMinorStepCount()
Return count of minor steps
public array( ezcGraphChartElementAxis::getSteps()
Return array of steps on this axis
public abstract bool ezcGraphChartElementAxis::isZeroStep()
Is zero step
public ezcGraphBoundings ezcGraphChartElementAxis::render()
Render the axis
public void ezcGraphChartElementAxis::setFromPalette()
Set colors and border fro this element
public void ezcGraphChartElementAxis::__set()
__set
From ezcGraphChartElement
protected ezcGraphBoundings ezcGraphChartElement::getTitleSize()
Returns calculated boundings based on available percentual space of given bounding box specified in the elements options and direction of the box.
public abstract ezcGraphBoundings ezcGraphChartElement::render()
Renders this chart element
public void ezcGraphChartElement::setFromPalette()
Set colors and border fro this element
From ezcBaseOptions
public ezcBaseOptions ezcBaseOptions::__construct()
Construct a new options object.
public void ezcBaseOptions::merge()
Merge an array into the actual options object.
public bool ezcBaseOptions::offsetExists()
Returns if an option exists.
public mixed ezcBaseOptions::offsetGet()
Returns an option value.
public void ezcBaseOptions::offsetSet()
Set an option.
public void ezcBaseOptions::offsetUnset()
Unset an option.

Methods

addData

void addData( $values )

Add data for this axis

Parameters:
Name Type Description
$values array Value which will be displayed on this axis
Redefinition of:
Method Description
ezcGraphChartElementAxis::addData() Add data for this axis

calculateAxisBoundings

void calculateAxisBoundings( )

Calculate axis bounding values on base of the assigned values

Redefinition of:
Method Description
ezcGraphChartElementAxis::calculateAxisBoundings() Calculate axis bounding values on base of the assigned values

calculateMajorStep

void calculateMajorStep( float $min , float $max )

Calculate size of major step based on the span to be displayed and the defined MIN_MAJOR_COUNT constant.

Parameters:
Name Type Description
$min float Real data minimum
$max float Real data maximum

calculateMaximum

void calculateMaximum( float $min , float $max )

Calculate maximum value for displayed axe basing on real maximum and major step size

Parameters:
Name Type Description
$min float Real data minimum
$max float Real data maximum

calculateMinimum

void calculateMinimum( float $min , float $max )

Calculate minimum value for displayed axe basing on real minimum and major step size

Parameters:
Name Type Description
$min float Real data minimum
$max float Real data maximum

calculateMinorStep

void calculateMinorStep( float $min , float $max )

Calculate size of minor steps based on the size of the major step size

Parameters:
Name Type Description
$min float Real data minimum
$max float Real data maximum

getCoordinate

float getCoordinate( float $value )

Get coordinate for a dedicated value on the chart

Parameters:
Name Type Description
$value float Value to determine position for
Redefinition of:
Method Description
ezcGraphChartElementAxis::getCoordinate() Get coordinate for a dedicated value on the chart

getLabel

string getLabel( integer $step )

Get label for a dedicated step on the axis

Parameters:
Name Type Description
$step integer Number of step
Redefinition of:
Method Description
ezcGraphChartElementAxis::getLabel() Get label for a dedicated step on the axis

getMajorStepCount

integer getMajorStepCount( )

Return count of major steps

Redefinition of:
Method Description
ezcGraphChartElementAxis::getMajorStepCount() Return count of major steps

getMinorStepCount

integer getMinorStepCount( )

Return count of minor steps

Redefinition of:
Method Description
ezcGraphChartElementAxis::getMinorStepCount() Return count of minor steps

getNiceNumber

float getNiceNumber( float $float )

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.

Parameters:
Name Type Description
$float float Number to be altered

isZeroStep

bool isZeroStep( int $step )

Is zero step

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

Parameters:
Name Type Description
$step int Number of step
Redefinition of:
Method Description
ezcGraphChartElementAxis::isZeroStep() Is zero step
Documentation generated by phpDocumentor 1.4.3