CLASS Legend
(Defined in: jpgraph.php : 5276)
 Legend 
 Hide() 
 Pos() 
 SetColor() 
 SetFillColor() 
 SetFont() 
 SetLayout() 
 SetLineWeight() 
 SetShadow() 
 

Class usage and Overview
This class is responsible for drawing a legend at the specified position in the graph. Individual data series are added by calling it's Add() method.

This is all handled by the framework. Legend is instantiated in the graph as instance variable legend. When stroking individual plots this instance variable is used by the individual Legend() methods in the plot classes to add whatever the individual plots need to add.

 


Class Methods

 

 

function Hide($aHide)
Hide legend box

ArgumentDefaultDescription
$aHide true True = hide

Description
Hides the legend. 

Example

$graph->legend->Hide();

 

 

function Pos($aX,$aY,$aHAlign,$aVAlign)
Specify the position for the legend box

ArgumentDefaultDescription
$aX  X coordinate
$aY  Y coordinate
$aHAlign "right" Horizontal alignment
$aVAlign "top" Vertical alignment

Description
Set the position of the legend box on the Graph. The alignment arguments determine how the position of the legend box should be interpretated, i.e from what position on the Graph should the fraction be counted. ('right' uses the right side and positoins the legend with its left side according to the specified fraction and so on). Possible alignemts are:

Horizontal: 'left','right','center'
Vertical: 'bottom','top','center'

Please note that the X and Y positions should be give as fractions , i.e Pos(0.1,0.1)

If the alignment is not given the the default is 'right','top' 

Example

$graph->legend->Pos(0.05,0.1);

 

 

function SetColor($aColor)
Set color on frame around box

ArgumentDefaultDescription
$aColor  Color

Description
Specify the color fo the frame around the legend box. Please note that this does not affect the fill color of the legend box. 
 
See also
Legend::SetFillColor

Example

$graph->legend->SetColor('lightblue');

 

 

function SetFillColor($aColor)
Specify fill color for legend box

ArgumentDefaultDescription
$aColor  Fill color

Description
Specify the background color for the legend box. The properties for the legend is noramlly accessed through the graph instance variable '$legend' 
 
See also
Legend::SetColor

Example

$graph->legend->SetFillColor('lightblue');

 

 

function SetFont($aFamily,$aStyle,$aSize)
Set font for texts in legend box.

ArgumentDefaultDescription
$aFamily  Font family
$aStyle FS_NORMAL Font style
$aSize 10 Font size

Description
Set font for texts in legend box. 

Example

$graph->legend->SetFont(FF_FONT2,FS_NORMAL);

 

 

function SetLayout($aDirection)
Specify vertical or horizontal legend layout

ArgumentDefaultDescription
$aDirection LEGEND_VERT Layout for legend box

Description
The legend box can either have the legend stacke vertically or horizontally. The default is vertically stacked legends.

Allowed arguments: LEGEND_VERT,LEGEND_HOR

Please note that horizontal layout is only suitable for a few legends since it makes use of quite a lot of horizontal space. 

Example

// Put a horizontal legend box at the bottom of the graph
$graph->legend->Pos(0.5,0.0.5,'left','bottom');
$graph->legend->SetLayout(LEGEND_HOR);

 

 

function SetLineWeight($aWeight)
Set the line width for the indicators.

ArgumentDefaultDescription
$aWeight  Line weight in pixels

Description
Specify the line width for the color boxes that are used as indicators. 

Example

$graph->legend->SetLineWeight(2);

 

 

function SetShadow($aShow,$aWidth)
Add a drop shadow to the legend box

ArgumentDefaultDescription
$aShow 'gray' True = show drop shadow
$aWidth 2 Width of drop shadow in pixels

Description
Add a drop down shadow for the legend box. 

Example

// Use a shadow width default width
$graph->legend->SetShadow();