Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcGraphChartElement

Graph::ezcGraphChartElement

Class ezcGraphChartElement

Base class for chart elements

The base class for chart elements. Chart elements can be understood as widgets or layout container inside the chart. The actual transformation to images happens inside the renderers. They represent all elements inside the chart and contain mostly general formatting options, while the renderer itself might define additional formatting options for some chart elments.

Important chart elements for example are:

  • Chart title (ezcGraphChartElementText)
  • Chart legend (ezcGraphChartElementLegend)
  • The axis (ezcGraphChartElementNumericAxis, ezcGraphChartElementLogarithmicalAxis, ezcGraphChartElementLabeledAxis, ezcGraphChartElementDateAxis)
  • ...
The position of chart elements is defined in the $position property. The effect this has on the visual representation depends on the actual type of the chart element.

Each chart element may be configured with options similar to CSS, used with HTML to define the general style of the repsective element:

  • $padding & $margin defne the distance of the border from inner elements / other chart elements.
  • $borderWidth & $border define the style of the border used around the chart element
  • $background defines the background color of the chart element. As always this may be a (semi-) transparent color.
A typical example with some layout for the chart title element could look like:

  1.   $graph = new ezcGraphPieChart();
  2.   $graph->data['example'] = new ezcGraphArrayDataSet( array(
  3.       'Foo' => 23,
  4.       'Bar' => 42,
  5.   ) );
  6.  
  7.   // Set a title and format the title element
  8.   $graph->title              = 'Example formatted pie chart';
  9.   $graph->title->margin      = 2;
  10.   $graph->title->background  = '#FFFFFF80';
  11.   $graph->title->border      = '#FFFFFF';
  12.   $graph->title->borderWidth = 1;
  13.   $graph->title->margin      = 1;
  14.   $graph->title->padding     = 1;
  15.  
  16.   // Format the legend element
  17.   $graph->legend->margin      = 2;
  18.   $graph->legend->background  = '#FFFFFF80';
  19.   $graph->legend->border      = '#FFFFFF';
  20.   $graph->legend->borderWidth = 1;
  21.   $graph->legend->margin      = 1;
  22.   $graph->legend->padding     = 1;
  23.  
  24.   $graph->background->background = '#888a85';
  25.  
  26.   $graph->render( 400, 250, 'element.svg' );

Source for this file: /Graph/src/interfaces/element.php

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

Descendants

Child Class Description
ezcGraphChartElementBackground Chart element representing the background.
ezcGraphChartElementLegend Class to represent a legend as a chart element
ezcGraphChartElementAxis Class to represent an axis as a chart element
ezcGraphChartElementText Chart element to display texts in a chart

Properties

ezcGraphColor read/write $background
Background color of chart element.
ezcGraphColor read/write $border
Border color of chart element.
int read/write $borderWidth
Border width.
ezcGraphBoundings read $boundings
Boundings of this elements.
ezcGraphFontOptions read/write $font
Font used for this element.
bool read $fontCloned
Indicates if font configuration was already cloned for this specific element.
float read/write $landscapeTitleSize
Percentage of boundings which are used for the title with position top or bottom.
int read/write $margin
Distance between outer boundings and border of an element.
int read/write $maxTitleHeight
Maximum size of the title.
int read/write $padding
Distance between border and content of element.
float read/write $portraitTitleSize
Percentage of boundings which are used for the title with position left, right or center.
int read/write $position
Integer defining the elements position in the chart.
string read/write $title
Title of chart element.

Inherited Member Variables

From ezcBaseOptions
protected ezcBaseOptions::$properties

Method Summary

protected ezcGraphBoundings getTitleSize( $boundings , [ $direction = ezcGraph::HORIZONTAL] )
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 render( $renderer , $boundings )
Renders this chart element
public void setFromPalette( $palette )
Set colors and border fro this element

Inherited Methods

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

getTitleSize

ezcGraphBoundings getTitleSize( $boundings , [int $direction = ezcGraph::HORIZONTAL] )

Returns calculated boundings based on available percentual space of given bounding box specified in the elements options and direction of the box.

Parameters:
Name Type Description
$boundings ezcGraphBoundings
$direction int

render

ezcGraphBoundings render( ezcGraphRenderer $renderer , $boundings )

Renders this chart element

This method receives and returns a part of the canvas where it can be rendered on.

Parameters:
Name Type Description
$renderer ezcGraphRenderer
$boundings ezcGraphBoundings
Redefined in descendants as:
Method Description
ezcGraphChartElementBackground::render() Render the background 
ezcGraphChartElementLegend::render() Render a legend 
ezcGraphChartElementAxis::render() Render the axis 
ezcGraphChartElementText::render() Render the text 

setFromPalette

void setFromPalette( ezcGraphPalette $palette )

Set colors and border fro this element

Parameters:
Name Type Description
$palette ezcGraphPalette Palette
Redefined in descendants as:
Method Description
ezcGraphChartElementBackground::setFromPalette() Set colors and border for this element 
ezcGraphChartElementAxis::setFromPalette() Set colors and border fro this element 
Documentation generated by phpDocumentor 1.4.3