Class PiePlot
(Defined in: jpgraph_pie.php : 24)
 
 PiePlot 
 Explode() 
 ExplodeAll() 
 ExplodeSlice() 
 SetCenter() 
 SetColor() 
 SetCSIMTargets() 
 SetGuideLines() 
 SetGuideLinesAdjust() 
 SetLabelPos() 
 SetLabels() 
 SetLabelType() 
 SetLegends() 
 SetShadow() 
 SetSize() 
 SetSliceColors() 
 SetStartAngle() 
 SetTheme() 
 SetValueType() 
 ShowBorder() 
 __construct() 
 

Class usage and Overview
Creates a new Pie plot from the supplied data.

By default the value (if enabled through the $pie->label->show() ) close to each slice will have a label corresponding to the percentage of that slice.

Each plot may have an arbitrary title which can be accessed through the ?title? property in the PiePlot class. The title will be automatically centred on top of the PiePlot clear of any possible labels. To set the title use the Set() method , i.e. $plot->title->Set(?MyTitle?).

To format the slice labels use the SetFormat() method of the value class.

 

See also related classes:
PieGraph and PiePlot3D

 


Class Methods

 

PiePlot ::
Explode($aExplodeArr)
Explode one or more slices as specified radius.

ArgumentDefaultDescription
$aExplodeArr  Explode specification

Description:
To emphasise a specific slice it can be exploded, i.e moved out fro the center of the pie plot. This method will allow you to specify what slices and to waht radius you want them exploded.

If you only want to explode a single slice you could also use the ExplodeSlice() method.  
 

See also:

Example:

//To explode slice 0,2 to radius 100 you would call
$pieplot->Explode(array(100,0,100));

 

PiePlot ::
ExplodeAll($radius)
Explode all slices a specified amount

ArgumentDefaultDescription
$radius 20 Explode radius

Description:
Explode all slices a specified amount. If no radius is specified it will default to 20 pixels. 
 
See also:

Example:

$p1->ExplodeAll();

 

PiePlot ::
ExplodeSlice($e, $radius)
Explode a single slice a specified radius

ArgumentDefaultDescription
$e  Which slice to explode
$radius 20 Radius to explode to

Description:
Explode a single slice to a specific radius. 
 
See also:

Example:

// Explode slice number 2 (the third slice) using the default
// explode radius.
$pieplot->ExplodeSlice(2);

 

PiePlot ::
SetCenter($x, $y)
//---------------// PUBLIC METHODS

ArgumentDefaultDescription
$x  X-position as fraction of width
$y 0.5 Y-position as fraction of height

Description:
Set the center point for the PiePlot 
 
See also:

Example:

$pieplot->SetCenter(0.4,0.5);

 

PiePlot ::
SetColor($aColor)
Specify frame color for pie.

ArgumentDefaultDescription
$aColor  Color.

Description:
Set the color of the border around each slice. 
 
See also:

Example:

$pieplot->SetColor('red');

 

PiePlot ::
SetCSIMTargets($aTargets, $aAlts, $aWinTargets)
Specify URL targets for image maps

ArgumentDefaultDescription
$aTargets  No description available
$aAlts '' No description available
$aWinTargets '' No description available

Description:
Specify list of targets for the image map for each slice. The target should be a fully qualified URL.

Each slice will aslo have it's own 'alt' tag. Depending on the browser this tag is usually showed when the mouse is hold over a poarticular area on the image map. When formatting the alt strings can be specified as a printf() format string. The value supplied to the string will be the value for each slice. 
 

See also:

Example:

$targets = array('godetail1.html''gotodetail2.html' 'gotodetail3.html');
$alts = array('Year %d''Year %d''Year %d');

$pieplot->SetCSIMTargets($targets,$alts);

 

PiePlot ::
SetGuideLines($aFlg, $aCurved, $aAlways)
Enable guideline and set drawing policy

ArgumentDefaultDescription
$aFlg true TRUE=Enable guide lines
$aCurved true Curve the labels around the pie
$aAlways false Always use a guide line to the label

Description:
Enable guideline and set drawing policy for guide lines and labels 

Example:

$pieplot->SetGuideLines();

 

PiePlot ::
SetGuideLinesAdjust($aVFactor, $aRFactor)
Adjuste the distance between labels and labels and pie

ArgumentDefaultDescription
$aVFactor  Vertical fraction
$aRFactor 0.8 Radius factor

Description:
Adjuste the distance between labels and labels and pie 

Example:

$graph->xaxis->scale->SetGuideLinesAdjust(1.7);

 

PiePlot ::
SetLabelPos($aLblPosAdj)
Adjust the positoin of slice labels

ArgumentDefaultDescription
$aLblPosAdj  Position as fraction of radius

Description:
Specify the position of the labels for each slice as a fraction of the radius.

Note: The adjustment affect both manually speicfied labels with SetLabels() as well as automtic labels.  
 

See also:

Example:

$p1 = new PiePlot($data);
$p1->SetLabelPos(0.6);
$graph->Add($p1);

 

PiePlot ::
SetLabels($aLabels, $aLblPosAdj)
Specify individual text labels for all slices

ArgumentDefaultDescription
$aLabels  Arrays of strings
$aLblPosAdj "auto" Position as fraction of the radius

Description:
Normally pie slice gets assigned a label which displays either the percentage or the absolute value of a slice. These automtically asigned labels are positioned in a ring around the pie.
However, you can also manually assign a label to each slice individually with this method.
Each label can contain format specification so for example the label

"May %.1f%%"

would display the in the pie "May 28.3%" assuming you had choosen to use percentage values (SetLabelType())

The second parameter specifies where to position these labels. The position is specified as a fraction of the radius of the pie plot or as the special strine 'auto'. If you specify this string value JpGraph will automtically determine the best position for the labels inside the pie. This is the default if you don't explicitely specify the position.

If you specify a value > 1.0 then the labels will just be move further out. For example if you specify the position as 1.5 then the labels will move out a further 50% of the current pie radius.

Note: The actual alignment of the labels are dependent on the position. If the labels are just outside the pie they will be individually positioned according to the angle. If the labels are positioned inside the pie then the point of gravity within the text will be aligned with the specified position in the pie.  
 

See also:

Example:

$p1->SetLabelType(PIE_VALUE_PER);
$lbl = array("adam\n%.1f%%","bertil\n%.1f%%","kalle\n%.1f%%","peter\n%.1f%%","daniel\n%.1f%%","erik\n%.1f%%");
$p1->SetLabels($lbl);

 

PiePlot ::
SetLabelType($aType)
Should we display actual value or percentage?

ArgumentDefaultDescription
$aType  No description available

Description:
Specify if the value displayed by each slice (if the $pieplot->value->Show()) have been called shold be absolute or in percent.

The following values are allowed arguments:

The defauklt is to show percent. 

Example:

// Show absolute values
$pieplot->SetLabelType(PIE_VALUE_ABS);

// Display each label with postfix 'kr', e.g. each label will
// look like (for example) 23.5 kr
$pieplot->value->SetFormat('%d kr');
$pieplot->value->Show();

 

PiePlot ::
SetLegends($aLegend)
// Set label arrays

ArgumentDefaultDescription
$aLegend  Array of strings

Description:
Specify an array of text strings that should be used as legends for the slices.

Each text string can be formatted as a printf() format string since when printed they will be passed the value for that slice.

Tip: If you have many evry small slices then the labels close to the pie may be overwriting each other. In this case it is probably better to hide the labels by the slices and instead just show the values ion the legends. 

Example:

$legends = array('April (%d)','May (%d)','June (%d)');

$pieplot->SetLegends($legends);


 

PiePlot ::
SetShadow($aColor, $aDropWidth)
Add a drop shadow to the pie slices

ArgumentDefaultDescription
$aColor 'darkgray' Shadow color
$aDropWidth 4 Drop distance for shadow

Description:
Add a drop shadow to the pie slices.

This is often more affective if one or more slices are exploded. 

Example:

// Explode all slices
$p1->ExplodeAll(10);

// Add drop shadow
$p1->SetShadow();

 

PiePlot ::
SetSize($aSize)
// Size in percentage

ArgumentDefaultDescription
$aSize  Size of radius

Description:
If the value specified is between 0 and 1 then it is interpreted as a a fraction of either height or width, whatever is smallest, of the graph.

If the value is >1 then it is interpretated as an absolute size in pixels.  
 

See also:

Example:

$pieplot->SetSize(0.3);

 

PiePlot ::
SetSliceColors($aColors)
Override theme coplros for slices

ArgumentDefaultDescription
$aColors  Array of colors

Description:
Normally the colors of the slices are set according to what color-theme you are using. You can however, override this by supplying an array of colors to be used for the slices.

If you supply fewer colors than pie-slices than the colors will be re-used from the beginning of the array.  
 

See also:

Example:

$p1->SetSliceColors(array('red','green','blue'));

 

PiePlot ::
SetStartAngle($aStart)
Speciy start angel for first slice

ArgumentDefaultDescription
$aStart  Start angle in degrees

Description:
Normally the first slice is drawn at 0 degrees, i.e. 3'a clock. With this method you can adjust that to an arbitrary angle. Positive angle will rotate the slice clockwise and a negative angle will move the slice counter-clockwise.

The angle should be specified in degrees.  

Example:

$pieplot->SetStartAngle(45);

 

PiePlot ::
SetTheme($aTheme)
//Add the last point on the arc

ArgumentDefaultDescription
$aTheme  Theme name

Description:
Specify what color theme should be used for this pie. As of version 1.6.4 the following themes are available:  

Example:

$pieplot->SetTheme('water');

 

PiePlot ::
SetValueType($aType)
DEPRECATED: See SetLabelType()

ArgumentDefaultDescription
$aType  Value type

Description:
See SetLabelType() 
 
See also:

Example:

NA

 

PiePlot ::
ShowBorder($exterior, $interior)
// Should the circle around a pie plot be displayed

ArgumentDefaultDescription
$exterior true Display circle on the outer edge of pieplot
$interior true Display the lines between each slice

Description:
Show the lines between each slice and the border around the pie. 

Example:

// show both
$pieplot->ShowBorder();

 

PiePlot ::
__construct($data)
Constructor for PiePlots

ArgumentDefaultDescription
$data  Data array for Pie

Description:
Construct a new pie plot which later can be added to Piegraph 
 
See also:

Example:

$pieplot = new PiePlot($slicedata);
$piegraph->Add($pieplot);