Overview

Packages

  • None
  • PieChart

Classes

  • PieChart
  • PieChartColor
  • PieChartGD
  • PieChartImagick
  • Overview
  • Package
  • Class
  • Tree

Class PieChart

Abstract class that is designed to be extended for drawing pie charts with different graphics libraries. Use PieChartGD or PieChartImagick to actually draw your charts.

Direct known subclasses

PieChartGD, PieChartImagick
Abstract
Package: PieChart
Copyright: © Sam Christy 2013
Author: Sam Christy <sam_christy@hotmail.co.uk>
Version: v1.2
Licence: GNU GPL v3.0 <http://www.gnu.org/licenses/gpl-3.0.html>
Located at PieChart.php
Methods summary
public
# __construct( integer $width = 0, integer $height = 0, string $title = '', string|integer|array $textColor = 0x222222, string|integer|array $backgroundColor = 0xffffff )

Constructs the PieChart.

Constructs the PieChart.

Parameters

$width
integer
$width The width of the chart, in pixels.
$height
integer
$height The chart's height, in pixels.
$title
string
[$title] The chart's title.
$textColor
string|integer|array
[$textColor] The colour of the title and labels.
$backgroundColor
string|integer|array
[$backgroundColor] The color for the background.
public
# destroy( )

Frees the memory that was allocated to the image. Use this function to clean up after your pie chart when you're finished with it.

Frees the memory that was allocated to the image. Use this function to clean up after your pie chart when you're finished with it.

public
# setTitle( string $title, string $titleFont = NULL )

Sets the title's text. To remove the title, set it to ''.

Sets the title's text. To remove the title, set it to ''.

Parameters

$title
string
$title
$titleFont
string
[$titleFont] The name of the font file for the title.
public
# setLegend( boolean $displayLegend, string $legendFont = NULL )

Add or remove the chart's legend (it is displayed default).

Add or remove the chart's legend (it is displayed default).

Parameters

$displayLegend
boolean
$displayLegend Specify false to remove the legend or true to add one.
$legendFont
string
[$legendFont] The name of the font for the legend's text.
public
# setOutputQuality( integer $quality )

Set the quality for generating output in lossy formats.

Set the quality for generating output in lossy formats.

Parameters

$quality
integer
$quality An integer between 0 and 100 (inclusive).
public
# addSlice( string $name, float $value, string|integer|array $color )

Adds a new slice to the pie chart.

Adds a new slice to the pie chart.

Parameters

$name
string
$name The name of the slice (used for legend label).
$value
float
$value
$color
string|integer|array
$color The CSS colour, e.g. '#FFFFFF', 'rgb(255, 255, 255)'.
public
# removeSlice( string $name )

Removes the specified slice.

Removes the specified slice.

Parameters

$name
string
$name The name of the slice to be removed.
public
# draw( )

Draws the chart so that it is ready for output.

Draws the chart so that it is ready for output.

protected
# _output( integer $method, integer $format, string $filename )

For child classes to override, so that the output functions work.

For child classes to override, so that the output functions work.

Parameters

$method
integer
$method
$format
integer
$format
$filename
string
$filename
public boolean
# outputGIF( string $filename = 'pie-chart.gif' )

Echos the chart as a GIF and instructs the browser to display it inline.

Echos the chart as a GIF and instructs the browser to display it inline.

Parameters

$filename
string
[$filename] The filename for the picture.

Returns

boolean
true if successful, false otherwise (implementation-dependent).
public boolean
# outputJPEG( string $filename = 'pie-chart.jpg' )

Echos the chart as a JPEG and instructs the browser to display it inline.

Echos the chart as a JPEG and instructs the browser to display it inline.

Parameters

$filename
string
[$filename] The filename for the picture.

Returns

boolean
true if successful, false otherwise (implementation-dependent).
public boolean
# outputPNG( string $filename = 'pie-chart.png' )

Echos the chart as a PNG and instructs the browser to display it inline.

Echos the chart as a PNG and instructs the browser to display it inline.

Parameters

$filename
string
[$filename] The filename for the picture.

Returns

boolean
true if successful, false otherwise (implementation-dependent).
public boolean
# forceDownloadGIF( string $filename = 'pie-chart.gif' )

Echos the chart as a GIF and instructs the browser to force the user to save it.

Echos the chart as a GIF and instructs the browser to force the user to save it.

Parameters

$filename
string
[$filename] The filename for the picture.

Returns

boolean
true if successful, false otherwise (implementation-dependent).
public boolean
# forceDownloadJPEG( string $filename = 'pie-chart.jpg' )

Echos the chart as a JPEG and instructs the browser to force the user to save it.

Echos the chart as a JPEG and instructs the browser to force the user to save it.

Parameters

$filename
string
[$filename] The filename for the picture.

Returns

boolean
true if successful, false otherwise (implementation-dependent).
public boolean
# forceDownloadPNG( string $filename = 'pie-chart.png' )

Echos the chart as a PNG and instructs the browser to force the user to save it.

Echos the chart as a PNG and instructs the browser to force the user to save it.

Parameters

$filename
string
[$filename] The filename for the picture.

Returns

boolean
true if successful, false otherwise (implementation-dependent).
public integer
# saveGIF( string $filename )

Saves the chart as a GIF, in the specified location.

Saves the chart as a GIF, in the specified location.

Parameters

$filename
string
$filename

Returns

integer
true if successful, false otherwise (implementation-dependent)..
public integer
# saveJPEG( string $filename )

Saves the chart as a JPEG, in the specified location.

Saves the chart as a JPEG, in the specified location.

Parameters

$filename
string
$filename

Returns

integer
true if successful, false otherwise (implementation-dependent).
public integer
# savePNG( string $filename )

Saves the chart as a PNG, in the specified location.

Saves the chart as a PNG, in the specified location.

Parameters

$filename
string
$filename

Returns

integer
true if successful, false otherwise (implementation-dependent).
Constants summary
integer FORMAT_GIF 1
#
integer FORMAT_JPEG 2
#
integer FORMAT_PNG 3
#
integer OUTPUT_DOWNLOAD 1
#
integer OUTPUT_INLINE 2
#
integer OUTPUT_SAVE 3
#
Properties summary
protected mixed $slices
#
protected mixed $width
#
protected mixed $height
#
protected mixed $title
#
protected mixed $hasLegend
#
protected mixed $titleFont
#
protected mixed $legendFont
#
protected mixed $textColor
#
protected mixed $backgroundColor
#
protected mixed $canvas
#
protected mixed $quality
#
PieChart API documentation generated by ApiGen 2.8.0