This class contains all the graphical stuff. You'll find bellow a short summary of all the embeded
function and their related parameters. This documentation has last been updated to match release 1.27 changes.
pChart
void pChart($XSize,$YSize)
This function create a new chart object. This object will be used during all the steps of the graph creation. This
object will embed all the pChart functions.
// This will create a 700x230 picture
$MyPicture = new pChart(700,230);
drawBackground
void drawBackground($R,$G,$B)
This function can be used to set the graph background color. In many cases this isn't needed. The default graph
background color is set to white (255,255,255).
// This will draw a red background
$MyPicture->drawBackground(255,0,0);
drawRectangle
void drawRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B)
This function draw an aliased rectangle. The upper left and bottom right border positions are used as first 4 arguments.
The last 3 parameters are used to set the border color.
// This will draw a red square at (10,10)-(100,100)
$MyPicture->drawRectangle(10,10,100,100,255,0,0);
drawFilledRectangle
void drawFilledRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B,$DrawBorder=TRUE,$Alpha=100)
The syntax of this function is the same as the
drawRectangle function.
This function draw an aliased filled rectangle. The upper left and bottom right border positions are used as first 4 arguments.
The last R,G,B parameters are used to set the border color. You can specify if the aliased border will be drawn and the
transparency.
// This will draw a filled red square at (10,10)-(100,100)
$MyPicture->drawRectangle(10,10,100,100,255,0,0);
// This will draw a semi-transparent filled red square at (10,10)-(100,100)
$MyPicture->drawRectangle(10,10,100,100,255,0,0,FALSE,50);
drawRoundedRectangle
void drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)
This function draw an aliased rectangle with rounded corners. The upper left and bottom right border positions are used
as first 4 arguments. Argument #5 represents the radius of the rounded corner. The last 3 parameters are used to set the
border color.
// This will draw a red square with rounded corner at (10,10)-(100,100)
$MyPicture->drawRoundedRectangle(10,10,100,100,10,255,0,0);
drawFilledRoundedRectangle
void drawFilledRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)
The syntax of this function is the same as the
drawRoundedRectangle function.
This function draw an aliased filled rectangle with rounded corners. The upper left and bottom right border positions are used
as first 4 arguments. Argument #5 represents the radius of the rounded corner. The last 3 parameters are used to set the
border color.
// This will draw a red filled square with rounded corner at (10,10)-(100,100)
$MyPicture->drawFilledRoundedRectangle(10,10,100,100,10,255,0,0);
drawCircle
void drawCircle($Xc,$Yc,$Height,$R,$G,$B,$Width=0)
This function draw an aliased circle at position ($Xc,$Yc) with the specified radius. The last 3 parameters are used to set the
border color.
Width is used to draw ellipses.
// This will draw a red circle at (100,100) with a radius of 50 pixel
$MyPicture->drawCircle(100,100,50,255,0,0);
drawFilledCircle
void drawFilledCircle($Xc,$Yc,$Height,$R,$G,$B,$Width=0)
The syntax of this function is the same as the
drawCircle function.
This function draw a filled aliased circle at position ($Xc,$Yc) with the specified radius. The last 3 parameters are used
to set the border and filling color.
Width is used to draw ellipses.
// This will draw a red filled circle at (100,100) with a radius of 50 pixel
$MyPicture->drawFilledCircle(100,100,50,255,0,0);
drawEllipse
void drawEllipse($Xc,$Yc,$Height,$Width,$R,$G,$B)
This function draw an aliased ellipse at position ($Xc,$Yc) with the specified height and width.
The last 3 parameters are used to set the border color.
// This will draw a red ellipse at (100,100) with a width of 50 pixel and height of 25 pixel
$MyPicture->drawEllipse(100,100,50,25,255,0,0);
drawFilledEllipse
void drawFilledEllipse($Xc,$Yc,$Height,$Width,$R,$G,$B)
The syntax of this function is the same as the
drawEllipse function.
This function draw a filled aliased ellipse at position ($Xc,$Yc) with the specified height and width.
The last 3 parameters are used to set the border and filling color.
// This will draw a red filled ellipse at (100,100) with a width of 50 pixel
// and height of 25 pixel
$MyPicture->drawFilledEllipse(100,100,50,25,255,0,0);
drawLine
void drawLine($X1,$Y1,$X2,$Y2,$R,$G,$B,$GraphFunction=FALSE)
This function will draw an aliased line between points (X1,Y1) and (X2,Y2). The last 3 parameters are used
to set the line color. The last optional parameter is used for internal calls made by graphing function. If
set to TRUE, only portions of line inside the graph area will be drawn.
// This will draw a red line between point (0,0) and (100,100)
$MyPicture->drawLine(0,0,100,100,255,0,0);
drawDottedLine
void drawDottedLine($X1,$Y1,$X2,$Y2,$DotSize,$R,$G,$B)
This function will draw an aliased dotted line between points (X1,Y1) and (X2,Y2). The last 3 parameters are used
to set the line color. Parameter #5 is used to specify the dot size ( 2 will draw 1 point every 2
points )
// This will draw a red dotted line between point (0,0) and (100,100)
// Dots will consist of 5 solid points followed by a hole of 5 points
$MyPicture->drawDottedLine(0,0,100,100,10,255,0,0);
drawAlphaPixel
void drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B)
This function will draw an alpha pixel at position (X,Y). $Alpha is used to specify the transparency factor
( between 0 and 100 ) The last 3 parameters are used to set the pixel color.
// This will draw a red pixel at position (100,100) and a transparency factor of 50%
$MyPicture->drawAlphaPixel(100,100,50,255,0,0);
drawFromPNG
void drawFromPNG($FileName,$X,$Y,$Alpha=100)
This function allows you to merge an external PNG picture with your graph specifying the position and
the transparency.
// This will put the picture "test.png" in the top left corner
$MyPicture->drawFromPNG("test.png",0,0);
// This will put the picture "test.png" at (20-20) with 50% transparency
$MyPicture->drawFromPNG("test.png",20,20,50);
drawFromGIF
void drawFromGIF($FileName,$X,$Y,$Alpha=100)
This function allows you to merge an external GIF picture with your graph specifying the position and
the transparency.
// This will put the picture "test.gif" in the top left corner
$MyPicture->drawFromGIF("test.gif",0,0);
// This will put the picture "test.gif" at (20-20) with 50% transparency
$MyPicture->drawFromGIF("test.gif",20,20,50);
drawFromJPG
void drawFromJPG($FileName,$X,$Y,$Alpha=100)
This function allows you to merge an external JPG picture with your graph specifying the position and
the transparency.
// This will put the picture "test.jpg" in the top left corner
$MyPicture->drawFromGIF("test.jpg",0,0);
// This will put the picture "test.jpg" at (20-20) with 50% transparency
$MyPicture->drawFromGIF("test.jpg",20,20,50);
setCurrency
void setCurrency($Currency)
Use this function to set the currency symbol.
// This will set the $ symbol
$MyPicture->setDateFormat(""$");
setDateFormat
void setDateFormat($Format)
Use this function to set date format in the PHP notation. (see
the PHP documentation ).
The default format that will be used is
d/m/Y suitable for dates.
// This will set the date format to be hours:minutes:seconds
$MyPicture->setDateFormat("H:i:s");
setFontProperties
void setFontProperties($FontName,$FontSize)
This function is used to set the font properties that will be used by all function drawing text on the graph.
Please note that the fontname must be in the current path! ( Windows & *ux version of PHP are not handling
fonts exactly the same way ).
// This will set the font to verdana 10 pixel height
$MyPicture->setFontProperties("verdana.ttf",10);
setGraphArea
void setGraphArea($X1,$Y1,$X2,$Y2)
A call to this function is mandatory when creating a graph. The upper left and bottom right border positions are used
as arguments. This area will be used to draw graphs, grid, axis & more. Calling this function will not draw anything
this will only set the graph area boundaries.
// This will set the graph area to (30,20)-(100,80)
$MyPicture->setGraphArea(30,20,100,80);
setFixedScale
void setFixedScale($VMin,$VMax,$Divisions=5,$VXMin=0,$VXMin=0,$XDivisions=5)
You can use this function to skip the automatic scaling. VMin and VMax will be used to render the
graph.
// This will set the graph scale to 0 - 100
$MyPicture->setFixedScale(0,100);
// For a scatter chart with 5 hor/ver divisions
$MyPicture->setFixedScale(0,100,5,0,100,5);
setShadowProperties
void setShadowProperties($ShadowXDistance=4,$ShadowYDistance=4,$ShadowRColor=60,$ShadowGColor=60,$ShadowBColor=60)
Use this function to set shadow properties. Can only be used with the exploded pie chart today.
// Activate the shadow with default settings
$MyPicture->setShadowProperties();
setLineStyle
void setLineStyle($Width=1,$DotSize=0)
This function allow you to customise the way lines are drawn in charts. This function only applies
during chart drawing calls ( line charts,.. ). You can specify the width of the lines & if they are
dotted.
// This will set line width to 2px
setLineStyle(2);
// This will set line width to 1px dotted ( 4 drawn, 4 empty..)
setLineStyle(1,4);
addBorder
void addBorder($Width=3,$R=0,$G=0,$B=0)
Use this function to add a border to your picture. Be carefull, drawing a border will change all the chart components positions,
thus this call must be the last one before one of the rendering methods!!! You can specify the Width of the border and its
color. The width and height of the picture will be modified by 2x the Width value.
// This will add a two pixel size border to the picture.
$MyPicture->addBorder($Width=2);
clearScale
void clearScale()
You'll need to call this function only if you're planning to draw a second chart in the rendered picture. Calling
this function will clear the current scaling parameters thus you'll need to call again the drawScale function
before drawing any new chart.
// Reset the scaling to prepare a new chart
$MyPicture->clearScale();
clearShadow
void clearShadow()
Use this function to deactivate the shadow options. Drawing shadows is time and CPU intensive. Shadows are today
accurate for line & curve charts.
// Deactivate the shadow functions
$MyPicture->clearShadow();
createColorGradientPalette
void createColorGradientPalette($R1,$G1,$B1,$R2,$G2,$B2,$Shades)
This function will fill the color palette with 10 shades between the two RGB colors 0,0,0 and 100,100,100. This
will produce grey shades. (Palette ID 0-9 will be filled)
// Deactivate the shadow functions
$MyPicture->createColorGradientPalette(0,0,0,100,100,100,10);
drawGraphArea
void drawGraphArea($R,$G,$B,$Stripe=FALSE)
This function will draw the graph area background color. The same result can be obtained using the drawFilledRectangle
function and giving coordinates manualy. The R,G,B 3 parameters are used to set the filling color. If strip is set
to TRUE, this will draw thin 45 degree strip with a color of -15.
// This will set the background color of the graph area to a soft grey
$MyPicture->drawGraphArea(250,250,250);
drawScale
void drawScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1,$RightScale=FALSE)
This function will draw both axis and write values on it. You can disable the labelling of the axis setting $DrawTicks
to FALSE. $Angle can be used to rotate the vertical ticks labels. $Decimal specify the number
of decimal values we want to keep. Setting DrawTicks to false will not draw vertical & horizontal ticks on the
axis ( labels will also not be written ).
Today there is four way of computing scales :
- Getting Max & Min values per serie : ScaleMode =
SCALE_NORMAL
- Like the previous one but setting the min value to 0 : ScaleMode =
SCALE_START0
- Getting the series cumulative Max & Min values : ScaleMode =
SCALE_ADDALL
- Like the previous one but setting the min value to 0 : ScaleMode =
SCALE_ADDALLSTART0
This will depends on the kind of graph you are drawing, today only the stacked bar chart can use the
SCALE_ADDALL
mode. Drawing graphs were you want to fix the min value to 0 you must use the
SCALE_START0 option.
You can display only one X label every Xi labels using the $SkipLabels parameter.
Keeping $WithMargin to FALSE will make the chart use all the width of the graph area. For most graphs the rendering will be
better. In some circumstances you'll have to set it to TRUE ( introducing left & right margin ) : bar charts will require it.
See the
datastructure help for more informations on how to use the datasets.
// This will will draw both scales in black in automatic mode
$MyPicture->drawScale($Data,$DataDescription,SCALE_NORMAL,0,0,0);
// This can be used for bar graphs
$MyPicture->drawScale($Data,$DataDescription,SCALE_NORMAL,0,0,0,TRUE,0,0,TRUE);
// ..same but with a min value of 0
$MyPicture->drawScale($Data,$DataDescription,SCALE_START0,0,0,0,TRUE,0,0,TRUE);
// This can be used for stacked bar graphs
$MyPicture->drawScale($Data,$DataDescription,SCALE_ADDALL,0,0,0,TRUE,0,0,TRUE);
drawRightScale
void drawRightScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1)
This function is a wrapper of the drawScale() function. It takes the same parameters of the drawScale() function. The
scale values will be written on the right side of the graph area.
// This will will draw both scales in black in automatic mode
$MyPicture->drawRightScale($Data,$DataDescription,SCALE_NORMAL,0,0,0);
// This can be used for bar graphs
$MyPicture->drawRightScale($Data,$DataDescription,SCALE_NORMAL,0,0,0,TRUE,0,0,TRUE);
// ..same but with a min value of 0
$MyPicture->drawRightScale($Data,$DataDescription,SCALE_START0,0,0,0,TRUE,0,0,TRUE);
// This can be used for stacked bar graphs
$MyPicture->drawRightScale($Data,$DataDescription,SCALE_ADDALL,0,0,0,TRUE,0,0,TRUE);
drawXYScale
void drawXYScale(&$Data,&$DataDescription,$YSerieName,$XSerieName,$R,$G,$B,$Angle=0,$Decimals=1)
This function is used by scatter charts. It will compute everything needed to draw the associated line and
plot charts. You must specify the name of the two series that will be used as X and Y data. By default
this function will compute the min & max values of both series, anyway you can override the automatic
scaling by calling first the setFixedScale function.
See the
datastructure help for more informations on how to use the datasets.
// This will will draw both scales in black in automatic mode
$MyPicture->drawXYScale($Data,$DataDescription,"Serie1","Serie2",0,0,0);
// This can be used for bar graphs with X labels rotated
$MyPicture->drawXYScale($Data,$DataDescription,"Serie1","Serie2",0,0,0,45);
drawGrid
void drawGrid($LineWidth,$Mosaic=TRUE,$R=220,$G=220,$B=220,$Alpha=255)
This function will draw a grid over the graph area. $LineWidth will be passed to the drawDottedLine function.
The R,G,B 3 parameters are used to set the grid color. Setting Mosaic to true will draw grey area between two
lines. You can define the transparency factor of the mosaic area playing with the Alpha parameter.
// This will will draw a black grid over the graph area.
$MyPicture->drawGrid(4,FALSE,0,0,0);
// This will will draw a soft grid over the graph area with greyed area.
$MyPicture->drawGrid(4,TRUE);
drawLegend
void drawLegend($XPos,$YPos,$DataDescription,$R,$G,$B,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=FALSE)
This function will draw the legend of the graph ( serie color & serie name ) at the specified position.
The R,G,B parameters are used to set the background color. You can optionally provide the shadow color using
the Rs,Gs,Bs parameters. You can also customize the text color using the Rt,Gt,Bt. Setting Border to false remove
the surrounding box.
See the
datastructure help for more informations on how to use the datasets.
// This will will draw the name of the series at (30-30) in a white buble
$MyPicture->drawLegend(30,30,$DataDescription,255,255,255);
drawPieLegend
void drawPieLegend($XPos,$YPos,$Data,$DataDescription,$R,$G,$B)
This function will draw the legend of a pie graph ( serie color & value name ). Be carrefull, dataset used for pie chart are not the
same than for other line / curve / plot graphs. You can specify the position of the legend box and the background color.
See the
datastructure help for more informations on how to use the datasets.
// This will will draw the data values names at (10-10) with a light grey background
$MyPicture->drawPieLegend(10,10,$Data,$DataDescription,250,250,250);
drawTextBox
void drawTextBox($X1,$Y1,$X2,$Y2,$Text,$Angle=0,$R=255,$G=255,$B=255,$Align=ALIGN_LEFT,$Shadow=TRUE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=100)
Use this function to write text over the picture. You must specify the coordinate of the box where the text will be written
using the (X1,Y1)-(X2,Y2) parameters, the text angle and the text color with the R,G,B parameters. You can choose how the text
will be aligned with the Align parameter :
-
ALIGN_TOP_LEFT Use the box top left corner.
-
ALIGN_TOP_CENTER Use the box top center corner.
-
ALIGN_TOP_RIGHT Use the box top right corner.
-
ALIGN_LEFT Use the center left.
-
ALIGN_CENTER Use the center.
-
ALIGN_RIGHT Use the center right.
-
ALIGN_BOTTOM_LEFT Use the box bottom left corner.
-
ALIGN_BOTTOM_CENTER Use the box bottom center corner.
-
ALIGN_BOTTOM_RIGHT Use the box bottom right corner.
Use the Shadow parameter to define if the text will own a shadow. Specifying the BgR,BgG,BgB will draw fill the text area with the
associated color. The Alpha parameter will be applyed to the text box background.
// This will will draw a text box with a black background and a transparency of 30%
// the text will be written in white with a shadow
$MyPicture->drawTextBox(0,210,700,230,"My text goes here",0,255,255,255,ALIGN_RIGHT,TRUE,0,0,0,30);
drawTitle
void drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1,$Shadow=FALSE)
This function is used to write the graph title. Used with default parameters you must specify the bottom left
position of the text. If you are specifying $X2 and $Y2 the text will be centered horizontaly and verticaly
in the box of coordinates (X1,Y1)-(X2,Y2). $Value correspond to the text that will be written on the graph.
$R, $G and $B are used to set the text color. Setting Shadow to true will makes a shadow behind the text.
// This will write in black "This is the title" at coordinate (100,15)
$MyPicture->drawTitle(100,15,"This is the title",0,0,0);
drawTreshold
void drawTreshold($Value,$R,$G,$B,$ShowLabel=FALSE,$ShowOnRight=FALSE,$TickWidth=4,$FreeText=NULL)
This function will draw an horizontal treshold ( this is an easy way to draw the 0 line ). If
$ShowLabel is set to TRUE, the value of the treshold will be written over the graph. If $ShowOnRight
is set to TRUE, the value will be written on the right side of the graph. $R, $G and $B are used to set the line
and text color. Use $TickWidth to set the width of the ticks, if set to 0 this will draw a solid line. You can
optionnaly provide the caption of the treshold (by default the treshold value is used)
// This will draw a red line at vertical coordinate 0 ( using the graph coordinates system )
$MyPicture->drawTreshold(0,255,0,0);
setLabel
void setLabel($Data,$DataDescription,$SerieName,$ValueName,$Caption,$R=210,$G=210,$B=210)
This function will draw a label over the graph. You must specify the Data & DataDescription structures,
the serie name ( "Serie1" by default if only one ), the X position of the value in the Data array (will
be numeric starting at 0 if no AbsciseLabel are defined or the value of the selected Abscise serie if
specified), the caption that will displayed and optionally the color of the label. To see an example
click here.
See the
datastructure help for more informations on how to use the datasets.
// This will put a label containing the text "Important point!" on the 3rd point of Serie1 (-3)
$DataSet->AddPoint(array(1,4,-3,2,-3,3,2,1,0,7,4),"Serie1");
$MyPicture->setLabel($Data,$DataDescription,"Serie1","2","Important point!");
// This will put a label containing the text "February record!" on the 2nd point of Serie1 (2)
$DataSet->AddPoint(array(1,2,0),"Serie1");
$DataSet->AddPoint(array("Jan","Feb","Mar"),"Serie2");
$DataSet->SetAbsciseLabelSerie("Serie2");
$MyPicture->setLabel($Data,$DataDescription,"Serie1","Feb","February record!");
drawArea
void drawArea($Data,$Serie1,$Serie2,$R,$G,$B,$Alpha = 50)
This function will draw an area between two data series extracting the minimum and maximum value for each
X positions. You must specify the two series name and the area color. You can specify the transparency which
is set to 50% by default. To see an example
click here.
See the
datastructure help for more informations on how to use the datasets.
// This will draw an area between Serie1 and Serie3 with a transparency of 50%.
$MyPicture->drawArea($DataSet->GetData(),"Serie1","Serie3",239,238,227,50);
drawGraphAreaGradient
void drawGraphAreaGradient($R,$G,$B,$Decay,$Target=TARGET_GRAPHAREA)
You can use this function to fill the background of the picture or of the graph area with a color gradient pattern. You
must specify the starting color with its R,G,B values, the number of shades to apply with the Decay parameter and optionnaly
the target that can be :
-
TARGET_GRAPHAREA The currently defined graph area
-
TARGET_BACKGROUND The whole picture background
// This will draw a background gradient made of 50 shades of the 132,153,172 color
$MyPicture->drawGraphAreaGradient(132,153,172,50,TARGET_BACKGROUND);
drawRadarAxis
void drawRadarAxis($Data,$DataDescription,$Mosaic=TRUE,$BorderOffset=10,$A_R=60,$A_G=60,$A_B=60,$S_R=200,$S_G=200,$S_B=200,$MaxValue=-1)
This function will draw the axis for a radar graph. You can specify the border offset that will be apply in the drawing
area, the outer & inner axis color and the maximum value. Setting Mosaic to false will not draw greyed area between the
spider webs.
// This will draw the radar graph axis with auto settings
$MyPicture->drawRadarAxis($Data,$DataDescription);
// This will draw the radar graph axis with a border of 20px, black
// axis, soft grey inner axis, using 10 as max value.
$MyPicture->drawRadarAxis($Data,$DataDescription,TRUE,20,0,0,0,200,200,200,10);
setColorPalette
void setColorPalette($ID,$R,$G,$B)
This function can be used to change the color of one series. Series ID are starting at 0 for associated
data serie #1. You must provide an RGB color.
// This will set the color of the first serie to red
$MyPicture->setColorPalette(0,255,0,0);
loadColorPalette
void loadColorPalette($FileName,$Delimiter=",")
This function will load the color scheme from a text file. This file must be formated with three
values per line ( R,G,B ). By default the delimiter is a coma but you can specify it.
// This will load the palette from file includes/palette.txt using semicolon as delimiter
$MyPicture->loadColorPalette('includes/palette.txt','|');
reportWarnings
void reportWarnings($Interface="CLI")
Use this fonction to enable error reporting during the chart rendering. By default messages are redirected to
the console while using the render command and using GD while using the stroke command. You can force the errors
to be redirected to either CLI or GD specifying it as parameter.
// Enable error reporting
$MyPicture->reportWarnings();
// Enable error reporting and redirect to GD
$MyPicture->reportWarnings("GD");
writeValues
void writeValues($Data,$DataDescription,$Series)
You can use this function to display the values contained in the series on top of the charts.
It is possible to specify one or multiple series to display using and array.
// This will show the values of Serie1 on top of the charts
$MyPicture->writeValues($Data,$DataDescription,"Serie1");
// This will show the values of Serie2 and Serie3 on top of the charts
$MyPicture->writeValues($Data,$DataDescription,array("Serie2","Serie3"));
drawPlotGraph
void drawPlotGraph(&$Data,&$DataDescription,$BigRadius=5,$SmallRadius=2,$R2=-1,$G2=-1,$B2=-1,$Shadow=FALSE)
This function will draw a plot graph using all the registered series. Giving only the Data & DataDescription structure will
draw the basic plot graph, you can specify the radius ( external & internal ) of the plots. You can also specify the color
of the points ( will be unique in case of multiple series ). You can
see a sample here
superposing a line & a plot graph. Setting Shadow to true will draw a shadow under the plots.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a plot graph using automatic sizing and coloring
$MyPicture->drawPlotGraph($Data,$DataDescription);
drawXYPlotGraph
void drawXYPlotGraph(&$Data,&$DataDescription,$YSerieName,$XSerieName,$PaletteID=0,$BigRadius=5,$SmallRadius=2,$R2=-1,$G2=-1,$B2=-1)
This function is very similar as the drawPlotGraph function. You must specify the name of the two series that
will be used as X and Y coordinates and the color ID to use.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a plot scatter using Serie1 as Y and Serie2 as X
$MyPicture->drawXYPlotGraph($Data,$DataDescription,"Serie1","Serie2");
drawLineGraph
void drawLineGraph($Data,$DataDescription)
This function will draw a line graph using all the registered series. You can
see a sample here
superposing a line & a plot graph. This function does not have optional parameters this is the most basic one :)
See the
datastructure help for more informations on how to use the datasets.
// This will draw a line graph
$MyPicture->drawLineGraph($Data,$DataDescription);
drawXYGraph
void drawXYGraph(&$Data,&$DataDescription,$YSerieName,$XSerieName,$PaletteID=0)
This function will draw a scatter line graph. You must specify the X and Y series that will be used. You
can optionnaly set the color index in the current palette.
// This will draw a line scatter chart using Serie1 as Y and Serie2 as X
$MyPicture->drawXYGraph($Data,$DataDescription,"Serie1","Serie2");
drawFilledLineGraph
void drawFilledLineGraph($Data,$DataDescription,$Alpha=100,$AroundZero=FALSE)
This function will draw a filled line graph using all the registered series. You can
see a sample here.
You can provide the alpha value used when merging all series layers. If $AroundZero is set to TRUE, the
area drawn will be between the 0 axis and the line graph value.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a line graph
$MyPicture->drawLineGraph($Data,$DataDescription);
drawCubicCurve
void drawCubicCurve($Data,$DataDescription,$Accuracy)
This function will draw a curved line graph using all the registered series. You can
see a sample here
superposing a curve & a plot graph. This curve is using a cubic algorythm to process the average values between two points. You have to specify the accuracy
between two points, typicaly a 0.1 value is acceptable. the smaller the value is, the longer it will take to process the graph.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a cubic curve graph
$MyPicture->drawCubicCurve($Data,$DataDescription,.1);
drawFilledCubicCurve
void drawFilledCubicCurve($Data,$DataDescription,$Accuracy,$Alpha=100,$AroundZero=FALSE)
This function will draw a filled curved line graph using all the registered series. You can
see a sample here
superposing a curve & a plot graph. This curve is using a cubic algorythm to process the average values between two points. You have to specify the accuracy
between two points, typicaly a 0.1 value is acceptable. the smaller the value is, the longer it will take to process the graph.
You can provide the alpha value used when merging all series layers. If $AroundZero is set to TRUE, the
area drawn will be between the 0 axis and the line graph value.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a filled cubic curve graph with a transparency of 50%
$MyPicture->drawFilledCubicCurve($Data,$DataDescription,.1,50);
drawLimitsGraph
void drawLimitsGraph($Data,$DataDescription,$R=0,$G=0,$B=0)
This function will draw the minimum & maximum values for a specific point using all the registered series. You can
see a sample here.
You can optionaly specify the vertical line color.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a limit graph
$MyPicture->drawLimitsGraph($Data,$DataDescription);
drawBarGraph
void drawBarGraph($Data,$DataDescription,$Shadow=FALSE)
This function will draw a bar graph using all the registered series. You can
see a sample here.
When creating a bar graph, don't forget to set the
$WithMargin parameter of the
drawScale function to TRUE. Setting
$Shadow to TRUE will draw a shadow behind each series, this will also slow down a bit the renderer engine.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a bar graph with shadows
$MyPicture->drawBarGraph($Data,$DataDescription,TRUE);
drawStackedBarGraph
void drawStackedBarGraph($Data,$DataDescription,$Alpha=50,$Contiguous=FALSE)
This function will draw a stacked bar graph using all the registered series. You can
see a sample here.
When creating a bar graph, don't forget to set the
$WithMargin parameter of the
drawScale function to TRUE. Don't forget
to change the automatic scaling to
SCALE_ADDALL to have an accurate scaling mode. You can specify the transparency and if
the bars must be contiguous or with space (default)
See the
datastructure help for more informations on how to use the datasets.
// This will draw a stacked bar graph with a transparency of 70%
$MyPicture->drawStackedBarGraph($Data,$DataDescription,70);
drawOverlayBarGraph
void drawOverlayBarGraph($Data,$DataDescription,$Alpha=50)
This function will draw a superposed bar graph using all the registered series. You can
see a sample here.
You can provide the alpha value used when merging all series layers.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a bar graph with a default alpha factor of 50
$MyPicture->drawOverlayBarGraph($Data,$DataDescription);
drawRadar
void drawRadar($Data,$DataDescription,$BorderOffset=10,$MaxValue=-1)
This function will draw a line radar graph using all the registered series. You can
see a sample here.
You can provide a border offset and the max value ( must be the same than the one used with the DrawRadarAxis function for consistency )
See the
datastructure help for more informations on how to use the datasets.
// This will draw a line radar graph
$MyPicture->drawRadar($Data,$DataDescription);
drawFilledRadar
void drawFilledRadar($Data,$DataDescription,$Alpha=50,$BorderOffset=10,$MaxValue=-1)
This function will draw a filled radar graph using all the registered series. You can
see a sample here.
You can provide a border offset and the max value ( must be the same than the one used with the DrawRadarAxis function for consistency ) You
can also provide the layers transparency factor which is set to 50% by default.
See the
datastructure help for more informations on how to use the datasets.
// This will draw a line radar graph
$MyPicture->drawFilledRadar($Data,$DataDescription);
drawPieGraph
void drawPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$EnhanceColors=TRUE,$Skew=60,$SpliceHeight=20,$SpliceDistance=0,$Decimals=0)
This function will draw a 3D pie graph. To do so you must specify the Data & DataDescription array. Only one serie of data is allowed for pie graph. You can
associate a description of each value in another serie by marking it using the SetAbsciseLabelSerie() function. You must specify the center position of
the chart. You can also optionally specify the radius of the pie, if the percentage should be printed, the 3D skew factor and the height of all splices.
If $EnhanceColors is set to TRUE, pie edges will be enhanced. If SpliceDistance is greated than 0, the pie will be exploded. You can specify the number
of decimals you want to be displayed in the labels (default is 0 ).
By default no labels are written around the pie chart. You can use the following modes for the $DrawLabels parameter:
-
PIE_NOLABEL No labels displayed
-
PIE_PERCENTAGE Percentages are displayed
-
PIE_LABELS Series labels displayed
-
PIE_PERCENTAGE_LABEL Series labels & percentage displayed
See the
datastructure help for more informations on how to use the datasets.
// This will draw a pie graph centered at (150-150) with a radius of 100, no labels
$MyPicture->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150);
// This will draw a pie graph centered at (150-150) with a radius of 50 and percentages
$MyPicture->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150,50,PIE_PERCENTAGE);
// This will draw a pie graph centered at (150-150) with a radius of 100, captions and a skew factor of 30
$MyPicture->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150,100,PIE_PERCENTAGE,TRUE,30);
// This will draw a pie graph (..) exploded
$MyPicture->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150,100,PIE_PERCENTAGE,TRUE,30,10,10);
drawBasicPieGraph
void drawBasicPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$R=255,$G=255,$B=255,$Decimals=0)
This function will draw a classical non-exploded pie chart. To do so you must specify the Data & DataDescription array. Only one serie of data is allowed for pie graph. You can
associate a description of each value in another serie by marking it using the SetAbsciseLabelSerie() function. You must specify the center position of
the chart. You can also optionally specify the radius of the pie and if the percentage should be printed.
$R,$G,$B can be used to set the color of the line that will surround each pie slices. You can specify the number of decimals you want to be displayed in the labels (default is 0 )
By default no labels are written around the pie chart. You can use the following modes for the $DrawLabels parameter:
-
PIE_NOLABEL No labels displayed
-
PIE_PERCENTAGE Percentages are displayed
-
PIE_LABELS Series labels displayed
-
PIE_PERCENTAGE_LABEL Series labels & percentage displayed
See the
datastructure help for more informations on how to use the datasets.
// This will draw a pie graph centered at (150-150) with a radius of 100, no labels
$MyPicture->drawBasicPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150);
// This will draw a pie graph centered at (150-150) with a radius of 50 and percentages
$MyPicture->drawBasicPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150,50,PIE_PERCENTAGE);
// This will draw a pie graph centered at (150-150) with a radius of 100, captions and black borders
$MyPicture->drawBasicPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150,100,PIE_PERCENTAGE,0,0,0);
drawFlatPieGraph
void drawFlatPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL ,$SpliceDistance=0,$Decimals=0)
This function will draw a flat 2D pie graph. To do so you must specify the Data & DataDescription array. Only one serie of data is allowed for pie graph. You can
associate a description of each value in another serie by marking it using the SetAbsciseLabelSerie() function. You must specify the center position of
the chart. You can also optionally specify the radius of the pie and if the percentage should be printed.
If SpliceDistance is greated than 0, the pie will be exploded. You can specify the number of decimals you want to be displayed in the labels (default is 0 )
By default no labels are written around the pie chart. You can use the following modes for the $DrawLabels parameter:
-
PIE_NOLABEL No labels displayed
-
PIE_PERCENTAGE Percentages are displayed
-
PIE_LABELS Series labels displayed
-
PIE_PERCENTAGE_LABEL Series labels & percentage displayed
See the
datastructure help for more informations on how to use the datasets.
// This will draw a pie graph centered at (150-150) with a radius of 100, no labels
$MyPicture->drawFlatPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150);
// This will draw a pie graph centered at (150-150) with a radius of 50 and percentages
$MyPicture->drawFlatPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150,50,PIE_PERCENTAGE);
// This will draw a pie graph centered at (150-150) with a radius of 100, captions and slightly exploded
$MyPicture->drawFlatPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,150,100,PIE_PERCENTAGE,4);
drawFlatPieGraphWithShadow
void drawFlatPieGraphWithShadow(&$Data,&$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$SpliceDistance=0,$Decimals = 0)
This function is an alias of the drawFlatPieGraph function.
// This will draw a pie graph centered at (150-150) with a radius of 100, no labels
$MyPicture->drawFlatPieGraphWithShadow($DataSet->GetData(),$DataSet->GetDataDescription(),150,150);
getLegendBox
array getLegendBox($DataDescription)
This function evaluate the width and height of the box generated by the drawLegend. This will help
you to calculate dynamicaly the position where you want to print it (eg top-right). You must provide
the datadescription array as only parameter. This function will return and array containing in the first
row the width of the box and in the second row the height of the box.
See the
datastructure help for more informations on how to use the datasets.
// Retrieve the width and height of the legend box
$BoxSize = $MyPicture->getLegendBox($DataSet->GetDataDescription());
// Print the legend box always aligned in the top right corner with a padding of 10px
// assuming your pChart graph width is 600px
$Test->drawLegend(590-$BoxSize[0],10,$DataSet->GetDataDescription(),255,255,255);
setImageMap
void setImageMap($Mode=TRUE,$GraphID="MyGraph")
Use this function to start the recording of the image map that will be associated to the chart. Mode must be set to TRUE
to start recording. GraphID must be an unique identifier that will be used to retrieve the image map using Ajax techniques.
The image map will be written to the disk while calling one of the two render method.
// This will start the recording of the "Zob4458" image map.
$MyPicture->setImageMap(TRUE,"Zob4458");
getImageMap
getImageMap($MapName,$Flush=TRUE)
Use this function to retrieve an image map. Most of the time this function is used to answer an ajax asynchronous request. You
must specify the image map unique ID (provided while creating it with the setImageMap function). By default image map are flushed
once they are sent to the browser, you can keep them by setting the Flush parameter to FALSE.
If the image map cannot be found a 404 header is sent to the browser.
Calling this function will stop the execution of the script.
// This will sent the "Zob4458" image map and destroy the temp file
$MyPicture->getImageMap("Zob4458");
// This will sent the "Zob4458" image map and keepthe temp file
$MyPicture->getImageMap("Zob4458",FALSE);