Documentation Home
Examples
Pie Charts
Overview
Customizing the chart
Function Reference
Examples
Line & Bar Graphs
Overview
Adding data
Customizing the bars
Customizing the axes
Function Reference
Support
Installation
Version History
Technical Support

Pie Chart PHP Class function reference

Function List

Pie chart data functions
setTitle ( title:string )
addData ( label:string, value:number, colour:colour )
Customising the look of the pie chart
setBackground ( bg1:colour, bg2:colour )
setPadding ( padding:number )
setDefaultFont ( font:string )
setTitleStyle ( fontName:string, size:number, colour:colour )
setTitlePosition ( xpos:number, ypos:number )
setLegendWidth ( width:number )
setLegendTextStyle ( font:string, size:number, font:colour, font:between )
setLegendKeyStyle ( size:number, padding:number )
setLegendBoxStyle ( backgroundCol:colour, borderCol:colour, padding:number )
setLegendPosition ( xpos:number, ypos:number )
set3DEdgeStyle ( size:number, hardness:number, reverse:boolean )
setHoleSize ( size:number )
Image functions
drawPNG ( width:number, height:number, thumb_w:number, thumb_h:number )
drawJPEG ( width:number, height:number, quality:number, thumb_w:number, thumb_h:number )
savePNG ( filename:string, width:number, height:number, thumb_w:number, thumb_h:number )
saveJPEG ( filename:string, width:number, height:number, quality:number, thumb_w:number, thumb_h:number )

Pie chart data functions

setTitle ( title='' )

Sets the title to display in the image.
Parameters
  Type Default  
title string  
The title to display. If it is too long for one line it will be split onto multiple lines.

addData ( label, value, colour )

Adds a data item to the pie chart
Parameters
  Type Default  
label string  
The label for this item. This will be shown against the colour in the legend.
value number  
The value of this data item. The size of this value compared to the other values determines the size of this slice of the pie.
colour colour  
The colour of the slice of the pie chart.

Customising the look of the pie chart

setBackground ( bg1, bg2='same as bg1' )

Sets the background colour of the image, allowing you to create a vertical gradient by specifying a top and bottom colour.
Parameters
  Type Default  
bg1 colour  
Colour of background at the top of the image
bg2 colour same as bg1
Colour of background at the bottom of the image. If not specified, the background is the solid colour specified by Array.
Notes
Colours are specified as hexadecimal HTML colours.
Examples
$pie->setBackground( '99CCFF' );
Sets the background to light blue.
$pie->setBackground( 'DDDDDD', '999999' );
Sets the background to a gradient from light grey to slightly darker grey.

setPadding ( padding=20 )

Controls the spacing between the elements of the image - the pie chart, the title and the legend, and also the distance between these elements and the edge of the image.
Parameters
  Type Default  
padding number 20
Size of the padding in pixels.

setDefaultFont ( font )

v1.04b 
Sets the default font which will be used for the title, legend and any other text if you do not explicitly specify fonts for them. ChartLogix will look in the same directory as chartlogix.inc.php if you specify a font name without a path.
Parameters
  Type Default  
font string  
Font to use as the default

setTitleStyle ( fontName='Arial', size=15, colour=000000 )

Sets the style of the title.
Parameters
  Type Default  
fontName string Arial
Name of the font to use.
size number 15
Size of the font in points
colour colour 000000
Colour of the title, specified as a hexadecimal HTML colour.
Examples
$pie->setTitleStyle( "Verdana", 20, '000066' );
Sets the title style to Verdana, size 20, dark blue.

setTitlePosition ( xpos=0, ypos=0 )

Sets the position and alignment of the title
Parameters
  Type Default  
xpos number 0
Horizontal alignment of the title: -1 = Left aligned, 0 = Centred, 1 = Right aligned.
ypos number 0
Vertical position: 0 = Top, 1 = Bottom.

setLegendWidth ( width=40 )

Parameters
  Type Default  
width number 40
Percentage of the width of the image taken up by the legend.
Notes
Setting the legend width to 0 will hide the legend.
Examples
$pie->setLegendWidth( 50 );
Sets the legend to be 50% of the width of the image.

setLegendTextStyle ( font='Arial', size=10, font=000000, font=10 )

Sets the style of the text in the legend.
Parameters
  Type Default  
font string Arial
Font to use in the legend text.
size number 10
Size of text in points.
font colour 000000
Colour of the text, specified as a hexadecimal HTML colour.
font between 10
Spacing between items in the legend.
Examples
$pie->setLegendTextStyle( "Verdana", 8, '663300', 10 );

setLegendKeyStyle ( size=10, padding=10 )

Sets the style of the boxes next to the items in the legend.
Parameters
  Type Default  
size number 10
Size of the coloured squares.
padding number 10
Horizontal distance between the coloured squares and the text next to them.

setLegendBoxStyle ( backgroundCol, borderCol, padding )

Sets the style of the legend box.
Parameters
  Type Default  
backgroundCol colour  
Background colour.
borderCol colour  
Border colour.
padding number  
Padding between the legend box border and the contents of the box.
Examples
$pie->setLegendBoxStyle( 'FFFFCC', '333333', 20 );
Gives the legend box a light yellow background, dark grey border, and 20 pixels of padding.

setLegendPosition ( xpos=1, ypos=0 )

Sets the position of the legend.
Parameters
  Type Default  
xpos number 1
Horizontal position of legend. 0 = Left, 1 = Right.
ypos number 0
Vertical alignment of the title: -1 = Top, 0 = Middle, 1 = Bottom.
Examples
$pie->setLegendPosition( 0, 0 );
Sets the legend to be in the top left corner of the image.

set3DEdgeStyle ( size=0, hardness=0, reverse=false )

Gives the pie chart a 3D edge effect.
Parameters
  Type Default  
size number 0
The size of the 3D edge, as a proportion of the radius of the pie chart (eg. 0.1 is 10%)
hardness number 0
How visible the 3D effect is - from 0.0 (invisible) to 1.0 (very visible)
reverse boolean false
Reverses the light and dark parts of the shading
Notes
Specifying a hardness value but keeping a size of 0 will put a gradient on the pie chart without the 3D edge.

setHoleSize ( size=0 )

Sets the size of the hole in the pie chart.
Parameters
  Type Default  
size number 0
The size of the hole, as a proportion of the radius of the pie chart (eg. 0.1 is 10%)

Image functions

drawPNG ( width, height, thumb_w=0, thumb_h=0 )

Outputs a PNG image to the web browser, including the Content-type header.
Parameters
  Type Default  
width number  
Width of the image in pixels.
height number  
Height of the image in pixels.
thumb_w number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
thumb_h number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
Examples
$pie->drawPNG( 500, 400 );
$pie->drawPNG( 500, 400, 0, 100 );
Draws a chart at 500x400 pixels, then scales the image down to 100 pixels high before sending to the web browser.

drawJPEG ( width, height, quality=75, thumb_w=0, thumb_h=0 )

Outputs a JPEG image to the web browser, including the Content-type header.
Parameters
  Type Default  
width number  
Width of the image in pixels.
height number  
Height of the image in pixels.
quality number 75
JPEG Quality - from 0 (lowest quality, small file) to 100 (best quality, large file)
thumb_w number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
thumb_h number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
Examples
$pie->drawJPEG( 500, 400, 90 );

savePNG ( filename, width, height, thumb_w=0, thumb_h=0 )

Saves the chart as a PNG file.
Parameters
  Type Default  
filename string  
Name of the file.
width number  
Width of the image in pixels.
height number  
Height of the image in pixels.
thumb_w number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
thumb_h number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
Notes
The filename can be specified with an absolute path, or with a relative path, which is relative to the script which is being requested by the Web browser.
Examples
$pie->savePNG( 'chart1.png', 500, 400 );
Saves the chart as chart1.png in the same directory as the PHP script which is being executed.

saveJPEG ( filename, width, height, quality=75, thumb_w=0, thumb_h=0 )

Saves the chart as a JPEG file.
Parameters
  Type Default  
filename string  
Name of the file.
width number  
Width of the image in pixels.
height number  
Height of the image in pixels.
quality number 75
JPEG Quality - from 0 (lowest quality, small file) to 100 (best quality, large file)
thumb_w number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
thumb_h number 0
If you want to generate a thumbnail image sepcify either the width or the height. v1.04
Notes
The filename can be specified with an absolute path, or with a relative path, which is relative to the script which is being requested by the Web browser.
Examples
$pie->saveJPEG( 'images/charts/chart1.jpg', 500, 400 );
Saves the chart as chart1.jpg in the images/charts directory, relative to the PHP script which is being executed.
Home  |  Online Store  |  Documentation  |  ChartLogix Features  |  Terms & Conditions Copyright © 2008 CubeLogix Ltd