Graph: ezcGraphChartElementLegend
[ ]
[ Gallery ]
[ ]
[ ]
[ ]
[ ]
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 ezcGraphArrayDataSet( array(
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->render( 400, 250, '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:
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 :
From
ezcBaseOptions :
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
Generate legend from single dataset with on entry per data element
Parameters
generateFromDataSets
Generate legend from several datasets with on entry per dataset
Parameters
render
Render a legend
Parameters
| Name |
Type |
Description |
$renderer |
ezcGraphRenderer |
Renderer |
$boundings |
ezcGraphBoundings |
Boundings for the axis |
Redefinition of
Last updated: Mon, 21 Dec 2009