CLASS Legend
(Defined in: jpgraph.php : 7847)
 Legend 
 Hide() 
 Pos() 
 SetAbsPos() 
 SetColor() 
 SetColumns() 
 SetFillColor() 
 SetFont() 
 SetFrameWeight() 
 SetHColMargin() 
 SetLayout() 
 SetLeftMargin() 
 SetLineSpacing() 
 SetLineWeight() 
 SetMarkAbsHSize() 
 SetMarkAbsSize() 
 SetMarkAbsVSize() 
 SetPos() 
 SetReverse() 
 SetShadow() 
 SetVColMargin() 
 

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 SetAbsPos($aX,$aY,$aHAlign,$aVAlign)
Specify X and Y coordinate for the legend box

ArgumentDefaultDescription
$aX  x Coordinate
$aY  y Coordinate
$aHAlign "right" Horizontal anchor point
$aVAlign "top" Vertical Anchor point

Description
Specify X and Y coordinate for the legend box 

Example

// 10x10 pixels from the upper right corner
$graph->legend->SetAbsPos(10,10,'right','top')

 

 

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

ArgumentDefaultDescription
$aFontColor  Font coor
$aColor 'black' Frame color

Description
Specify the color for both the frame around the legend box as well as the font color used for the legend texts. Please note that this does not affect the fill color of the legend box. 
 
See also
Legend::SetFillColor

Example

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

 

 

function SetColumns($aCols)
Specify the number of text columns to use

ArgumentDefaultDescription
$aCols  Number of columns

Description
Specify the number of text columns to use in the legend text box. For graphs which have a large number of plots it might be necessary to specify 2 or more columns to avois that the legend box become to large.

By default i column us used. 

Example

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

 

 

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 SetFrameWeight($aWeight)
Specify the width of the frame around the Legend box

ArgumentDefaultDescription
$aWeight  Width in pixels

Description
Specify the width of the frame around the Legend box 

Example

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

 

 

function SetHColMargin($aXMarg)
Specify margin between columns in te legend

ArgumentDefaultDescription
$aXMarg  No description available

Description
Specify margin between columns in te legend 

 

 

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 SetLeftMargin($aXMarg)
Specify marging between the left edge and the first column

ArgumentDefaultDescription
$aXMarg  No description available

Description
Specify marging between the left edge and the first column 

 

 

function SetLineSpacing($aSpacing)
Extra vertical spacing (in pixels) between rows

ArgumentDefaultDescription
$aSpacing  Extra margin (in pixels)

Description
Extra vertical spacing (in pixels) between rows 

Example

// Add 5 pixels extra margin between each legend row
$graph->legend->SetLineSpacing(5);

 

 

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 SetMarkAbsHSize($aSize)

ArgumentDefaultDescription
$aSize  No description available

Description
No description available.

 

 

function SetMarkAbsSize($aSize)
Specify the size of the marker in pixels

ArgumentDefaultDescription
$aSize  Size in pixels

Description
Specify the size of the marker in pixels to be used in the legend. This is used for the plot marks, for example squares or circles, when you want to control what the size used in the legend should be.

It is often desirable to use a smaller size for the marks in the legend than in the graph itself. 

Example

$graph->legend->SetMarkAbsSize(6);

 

 

function SetMarkAbsVSize($aSize)

ArgumentDefaultDescription
$aSize  No description available

Description
No description available.

 

 

function SetPos($aX,$aY,$aHAlign,$aVAlign)
Alias for Pos. Specify Position for Legend

ArgumentDefaultDescription
$aX  X position
$aY  Y position
$aHAlign "right" Horizontal anchor point
$aVAlign "top" Vertical anchor point

Description
See Legend::Pos() 
 
See also
Legend::Pos

Example

$graph->legend->SetPos(0.05,0.5,'right','center');

 

 

function SetReverse($f)
Print the legend in reverse order

ArgumentDefaultDescription
$f true TRUE=In reverse order

Description
Print the legend in reverse order 

Example

$graph->legend->SetReverse();

 

 

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();

 

 

function SetVColMargin($aSpacing)
Specify the margin between rows in the legend

ArgumentDefaultDescription
$aSpacing  No description available

Description
Specify the margin between rows in the legend