Path

ez components / documentation / api reference / latest / graph


eZ Components latest

Graph: ezcGraphChartElementLegend

[ Tutorial ] [ Gallery ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcGraphChartElementLegend

Class to represent a legend as a chart element [source]
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. You can find more about the general formatting options for chart elements in the base class ezcGraphChartElement.
The legend chart element is used to display the legend of a chart. It can be deactivated by setting the legend to false, like:
 1.   $chart->legend false;
The position of the legend in the chart can be influenced by the postion property, set to one of the position constants from the ezcGraph base class, like ezcGraph::BOTTOM, ezcGraph::LEFT, ezcGraph::RIGHT, ezcGraph::TOP.
Depending on the position of the legend, either the $portraitSize (RIGHT, LEFT) or the $landscapeSize (TOP, BOTTOM) defines how much space will be aqquired for the legend.
 1.   $graph new ezcGraphPieChart();
 2.   $graph->data['example'new ezcGraphArrayDataSetarray(
 3.       'Foo' => 23,
 4.       'Bar' => 42,
 5.   ) );
 6.  
 7.   // Format the legend element
 8.   $graph->legend->background    '#FFFFFF80';
 9.  
10.   // Place at the bottom of the chart, with a height of 5% of the remaining
11.   // chart space.
12.   $graph->legend->position      ezcGraph::BOTTOM;
13.   $graph->legend->landscapeSize .05;
14.  
15.   $graph->render400250'legend.svg' );

Parents

ezcBaseOptions
   |
   --ezcGraphChartElement
      |
      --ezcGraphChartElementLegend

Properties

float read/write  $landscapeSize
Size of a landscape style legend in percent of the size of the complete chart.
float read/write  $minimumSymbolSize
Scale symbol size up to to percent of complete legends size for very big legends.
float read/write  $portraitSize
Size of a portrait style legend in percent of the size of the complete chart.
int read/write  $spacing
Space between labels elements in pixel.
int read/write  $symbolSize
Standard size of symbols and text in legends.

Member Variables

protected array $labels
Contains data which should be shown in the legend

array( array( 'label' => (string) 'Label of data element', 'color' => (ezcGraphColor) $color, 'symbol' => (integer) ezcGraph::DIAMOND, ), ... )

Inherited Member Variables

From ezcBaseOptions:
protected  ezcBaseOptions::$properties

Method Summary

protected ezcGraphBoundings calculateBoundings( $boundings )
Calculated boundings needed for the legend.
public void generateFromDataSet( $dataset )
Generate legend from single dataset with on entry per data element
public void generateFromDataSets( $datasets )
Generate legend from several datasets with on entry per dataset
public ezcGraphBoundings render( $renderer, $boundings )
Render a legend

Inherited Methods

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

calculateBoundings

ezcGraphBoundings calculateBoundings( $boundings )
Calculated boundings needed for the legend.
Uses the position and the configured horizontal or vertical size of a legend to calculate the boundings for the legend.

Parameters

Name Type Description
$boundings ezcGraphBoundings Avalable boundings

generateFromDataSet

void generateFromDataSet( ezcGraphDataSet $dataset )
Generate legend from single dataset with on entry per data element

Parameters

Name Type Description
$dataset ezcGraphDataSet  

generateFromDataSets

void generateFromDataSets( ezcGraphChartDataContainer $datasets )
Generate legend from several datasets with on entry per dataset

Parameters

Name Type Description
$datasets ezcGraphChartDataContainer  

render

ezcGraphBoundings render( ezcGraphRenderer $renderer, $boundings )
Render a legend

Parameters

Name Type Description
$renderer ezcGraphRenderer Renderer
$boundings ezcGraphBoundings Boundings for the axis

Redefinition of

Method Description
ezcGraphChartElement::render() Renders this chart element

Last updated: Mon, 21 Dec 2009