All classes are documented with their private and public methods as well as their parents to clearly show which methods have been overridden. Since PHP is not a strict typed language I have taken the liberty of specifying each method with the type you would call it with to make it clearer what is intended.
When properties are listed their Class (if any) are specified as a normal type. When arguments for methods have default arguments they are specified.
An overview of available methods are given for each class in a table format. For each class that extends another class the immediately parent class is also given for reference. Methods which are overridden in a child class is indicated as strike-through in the parent class to emphasise that the method in the child is used.
The class diagram below shows a simplified version of the overall (simplified) class hierarchy used in JpGraph.
The following section describes all the classes used in the library. For each class the file where it is defined is specified, and it’s class hierarchy.
Defined in file: jpgraph.php
Public
properties |
Class Axis
xaxis,yaxis,y2axis; Class Grid
sgrid,ygrid,y2grid; Class Image
img; Class Text
title; |
Public
methods |
Graph() Add() AddY2() AddText() Box() SetColor() SetMarginColor() SetFrame() SetShadow() SetScale() SetY2Scale() SetTickDensity() Stroke() |
Private
properties & methods |
Class
LinearScale xscale, yscale, y2scale; GetPlotsYMinMax() StrokeFrame() |
General
description
The Graph class is the main container class which controls the creation of the entire graph. You must always instantiate one instance to create a graph. Through this class one controls many overall settings of the image displayed.
Graph(int $width, int $height, String $cacheName=””)
Parameters:
Int width Width in pixel of the overall image generated
Int height Height in pixel of the overall image generated
String cacheName Name for picture in cache.
Description:
Creates a new graph. This is often the first call made to set-up a new graph..
If the cache name is specified then the method will first try to locate the named file in the “./cache/” directory rather then generating the graph on the fly. If the file is not there the graph will be generated and saved as the specified file. This file is the passed through to the browser.
If no cache name is specified then the graph will always be generated and the cache bypassed.
Before any other operation is performed on the graph a call to SetScale() should be made to finish the initialisation of the graph.
Returns:
NA
See also:
Class ImgStreamCache
Example:
$graph = new Graph(300,200); // Create a 300x200 big image to work with
Add(&Class Plot)
Parameters:
Class Plot Plot to be added to the graph
Description:
Each plot that should be displayed within the graph has to be added to the graph. This method will add the plot so it will use the “Left” Y-scale, (the normal Y scale).
Note that since the plot is added as a reference any changes you make to the original plot will also happen to the plot you have added to the graph.
Returns:
NA
See also:
AddY2(), SetScale()
Example:
$lineplot =
New LinePlot($datay);
$graph->Add($lineplot);
$lineplot->SetColor(“red”); // Will affect the graph
AddY2(&Class Plot)
Parameters:
Class Plot Plot to be added to the graph
Description:
Works the same way as Add() but the plot is added for use with the Y2 scale (the right Y scale) instead.
Returns:
NA
See also:
Add(), SetY2Scale()
Example:
$graph->new
Graph(300,200);
$graph->SetScale(“linlin”);
$graph->SetY2Scale(“linlog”);
$lineplot =
New LinePlot($datay);
$graph->AddY2($lineplot);
AddText(&Class Text)
Parameters:
Class Text Text object to be added to the graph
Description:
Adds an instance of the Text class to the graph, allowing arbitrary text to be placed anywhere in the graph.
Returns:
NA
See also:
Class Text
Example:
$caption=new
Text(“Figure 1. Temperature over time”,0.1,0.8);
$caption->SetFont(FONT1_BOLD);
$graph->AddText($caption);
SetBox(Boolean $box=true, Int $weight=1, Color $color="black")
Parameters:
Boolean $b Flag to set plotarea box on or off
Int weight Line weight for box
Color color Line color
Description:
This is used to specify whether the plot-area should have a rectangle around it and the specifics of that rectangle.
Note: As of version 1.0 the weight parameter is not honoured and hence the box will always be one pixel wide.
Returns:
NA
See also:
SetFrame()
Example:
$graph->new
Graph(300,200);
$graph->SetScale(“linlin”);
$graph->Box();
SetColor(Color $c)
Parameters:
Color $c Set the background color for the plot are
Description:
Sets the background color for the plot-area.
Returns:
NA
See also:
SetMarginColor()
Example:
$graph->SetColor(“wheat”);
SetMarginColor(Color $c)
Parameters:
Color $c Set the background color for the margins
Description:
Specifies the color of the area between the plot area and the edge of the image.
Returns:
NA
See also:
SetColor(), SetMargins()
Example:
SetFrame(Boolean $frame=true, Color $color="black", Int $weight=1)
Parameters:
Boolean frame Flag if the fram around the image should be drawn or not
Color color Color of the frame
Int weight Line weight for the frame
Description:
Sets a frame (rectangle) of the chosen color around the edges of the image.
Returns:
NA
See also:
SetBox()
Example:
$graph->SetFrame();
SetShadow(Boolean $shadow=true,int shadowWidth=4,Color shadowColor=grey40)
Parameters:
Boolean shadow Flag if the shadow should be displayed or not
Int shadowWidth Shadow width
Color shadowColor Shadow color
Description:
Sets a frame with a shadow around the entire image
Returns:
NA
See also:
SetFrame()
Example:
$graph->SetShadow()
SetScale(String $axtype,int $ymin=1,int $ymax=1,int $xmin=1,int $xmax=1)
Parameters:
String $axtype Type of scale
Int $ymin Min Y scale value
Int $ymax Max Y scale value
Int $xmin Min X scale value
Int $xmax Max X scale value
Description:
Specifies what kind of scales should be used in the graph. The following combinations are allowed
· Linear scale. Both X and Y axis
· Logarithmic scale. Both X and Y axis
· Text scale. Only on X axis
Any combination of these may be used. Linear and logarithmic scales are pretty straightforward. The text scale might deserve some explanation. The easiest way to think of the text scale is as a linear scale consisting of only natural numbers, i.e. 0,1,2,3,4,… . This scale is used when you just have a number of Y-values you want to plot in a consecutive order and don’t care about the X-values
To specify which combination of X and Y scales you want to use the $axtype parameter is specified. The following values are allowed
· “linlin” Linear X, Linear Y
· “linlog” Linear X, Log Y
· “textlin” Text X, Linear Y
·
“textog” Text X, Log Y
·
“loglin” Log X, Linear Y
·
“loglog” Log x, Log Y
It is normally recommended to use the auto-scaling feature since for most practical purposes it is good enough. However on rare occasions you might want to specify the limits yourself. This is then done by the rest of the parameters to the method.
Note: If you want to use a logarithmic scale you must make sure that the “jpgraph_log.php” is included.
Returns:
NA
See also:
SetY2Scale()
Example:
$graph->SetScale(“textlin”);
SetY2Scale(String $axtype, int $ymin, $ymax)
Parameters:
String $axtype Type of scale
Int $ymin Min Y scale value
Int $ymax Max Y scale value
Description:
The graph allows two different Y-scales to be used and you can choose which one you want to use for a specific plot by the way you are adding the plot to the graph, either by Add() or by AddY2() method.
This method works in the exact same way for the Y2 axis as the SetScale() method previously described.
Allowed values for the $axtype are
· “lin” Linear scale
· “log” Logarithmic scale
Note: If you want to use a logarithmic scale you must make sure that the “jpgraph_log.php” is included.
Returns:
NA
See also:
SetScale()
Example:
$graph = new Graph(300,200);
$graph->SetScale(“textlin”);
$graph->SetY2Scale(“log”);
SetTickDensity(int $densy=TICKD_NORMAL, int $densx=TICKD_NORMAL)
Parameters:
Int $densy Density hint for Y axis autoscaling
Int $densy Density hint for X axis autoscaling
Description:
This method is used to hint how many ticks the auto-scaling should try to fit on each of the axis.
The following defines may be used to hint to the auto-scaling how many ticks should be allocated
· TICKD_DENSE Small distance between ticks
· TICKD_NORMAL Default value
· TICKD_SPARSE Longer distance between ticks
· TICKD_VERYSPARSE Very few ticks
Returns:
NA
See also:
NA
Example:
$graph->SetTickDensity(TICKD_DENSE); // Many Y-ticks
Stroke()
Parameters:
NA
Description:
Should be the final method called in the script that generates a graph. This will generate the image and send it back to the browser
Returns:
NA
See also:
NA
Example:
$graph->Stroke()
Defined in file: jpgraph.php
Public
properties |
Class LinearScale scale; Class Text title; |
Public
methods |
Hide() HideFirstTickLabel() SetColor() SetWeight() SetTitle() SetTickLabels() SetTextTicks() SetLabelPos() SetFont() |
Private
properties & methods |
Axis() Stroke() |
General
description
The Axis class is used to represent both the X and Y axis in the graph. It is possible to control the individual properties of the axis such as color, weight, font used for labels, title etc through the method defined in this class.
Instances
$graph->xaxis
$graph->yaxis
$graph->y2axis
Axis(Class Image &$img, &$aScale, $color="black")
Parameters:
Class Image &$img Type of scale
Class LinearScale &$aScale Min Y scale value
Color $ymax Max Y scale value
Description:
Creates a new axis. A new axis can be either a X-axis or an Y-axis. To create a new axis one supplies an Image and a scale. It is also possible to specify the color: Colors may also be specified through the SetColor() method.
Returns:
NA
See also:
Class LinearScale, Class LogScale, Class Image
Example:
Hide(Boolean $h=true)
Parameters:
Boolean $h
Description:
Hides the axis if $=true
Returns:
NA
See also:
Example:
$graph->yaxis->Hide()
HideFirstTickLabel(Boolean
$flag=false)
Parameters:
Boolean $flag
Description:
If you (for esthetical reason) does not want to display the first tick label you call this method.
Returns:
NA
See also:
Example:
SetWeight(int $weight)
Parameters:
Int weight
Description:
Specify line weight of the axis.
Returns:
NA
See also:
SetColor()
Example:
$graph->yaxis->SetWeight(2)
SetColor(Color $color)
Parameters:
Color Color
Description:
Specified color of sxis.
Returns:
NA
See also:
SetWeight()
Example:
$graph->yaxis->SetColor()
SetTitle(String $t, String $adj="high")
Parameters:
String $t
String $adj
Description:
Specify
title for the axis. The title may also be accessed as the “title” property of
the axis. The title may be adjust to either in the middle, at the high end or
at the low end of the axis.
This
method is actually a shortcut for $axis->title->Set($t). To change the
specifics of the title (like color or font)
you apply the suitable method on the title property.
Returns:
NA
See also:
Example:
$graph->xaxis->SetColor(“red”);
$graph->xaxis->SetFont(FONT1_BOLD);
SetTickLabels(String Array $l)
Parameters:
String Array $l
Description:
Normally ticks are given numeric values corresponding to it’s position on the scale. However it is also possible to specify alternative labels, for example you might want to have the name of the months on the x-axis.
When using this method you should supply a value for each major tick mark.
Returns:
NA
See also:
Example:
$months = array(“Jan”,“Feb”,“Mar”,“Apr”,“May”,“June”);
$graph->xaxis->SetTickLabels($month);
SetTextTicks(int $step, int $start=0)
Parameters:
Int $step
Int $start
Description:
When you have specified a text scale for the X-axis by default every whole number is used as a major tick, i.e if you have 10 data-points the x-axis will have the labels (0,1,2,3,4,5,6,7,8,9). If you have many data-points you might not want to display all these labels. This method let’s you control which labels will be displayed.
The first parameter $step specifies that every $step ticks should be displayed. For example SetTextTicks(2) will cause every second label to be displayed so given the 10 data-points before the scale will now display (0,2,4,6,8).
The other parameter $start specifies which offset should the scale should start on, For example SetTextTicks(2,1), will generate the scale (1,3,5,7,9).
If you combine both SetTickLabels() and SetTextTicks() you can fully control which data-points have your specified text label.
Returns:
NA
See also:
SetTickLabels()
Example:
$month = array(“Feb”,”Apr”,”Jun”,”Aug”,”Oct”,”Dec”);
$graph->xaxis->SetTextTicks(2,1);
$graph->xaxis->SetTickLables($month)
SetLabelPos(int $pos)
Parameters:
Int $pos
Description:
Specify which side of the axis you want the text labels on. Valid values for $pos are (1, -1)
Returns:
NA
See also:
Example:
$graph->y2axis->SetLabelPos(-1); // Set labels to the left of the Y2 axis.
SetTitleSide(int $side)
Parameters:
Int $side
Description:
Specify which side of the axis you want the title lon. Valid values for $side are SIDE_LEFT, SIDE_RIGHT
This method currently only affects the Y-axis.
Returns:
NA
See also:
Example:
$graph->yaxis->SetTitleSide(SIDE_RIGHT);
SetFont(int $size, String $font="internal")
Parameters:
Int $size
String $font
Description:
Specify
font for labels in the axis.
Returns:
NA
See also:
Example:
Stroke(Class LinearScale $otherAxisScale)
Parameters:
Class LinearScale $otherAxisScale
Description:
Draws the axis. Since the position of the axis is specified in relation to the other axis it is also necessary to supply the other scale as a parameter to draw the axis. By default the axis is place at the lower end at the other axis if not otherwise specified with a call to Pos().
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Public
properties |
Class LinearScale scale; Class Text title; |
Public
methods |
SetColor() SetWeight() SupressZeroLabel() SupressMinorTickMarks() SupressFirst() SetPrecision() SetDirection() SetMarkColor() SetWeight() SetDirection() |
Private
properties & methods |
Class Image
img; Stroke() Ticks() GetMinTickAbsSize() GetMajTickAbsSize() |
General
description
Abstract base class for the linear and logarithmic ticks. Internal class which does never have to be instantiated. Responsible for the overall layout and format for tick lines. Note that the actual tick labels are drawn by the Axis class based on tick position calculations computed by actual subclasses to this class.
Instances
$axis->scale->ticks
Ticks(&$scale)
Parameters:
$scale Scale to fit ticks on
Description:
Construct ticks for the specified scale.
Returns:
NA
See also:
LinerTicks(), LogTicks()
Example:
GetMinTickAbsSize()
Parameters:
NA
Description:
Get distance in pixels between minor tick marks.
Returns:
NA
See also:
Example:
SupressZeroLabel(Boolean $z=true)
Parameters:
$z TRUE/FALSE
Description:
Specify whether a label with numeric value 0 should be displayed
Returns:
NA
See also:
Example:
SupressMinorTickMarks(Boolean $tm=true)
Parameters:
$tm TRUE/FALSE
Description:
Specify whether minor tick marks should be displayed or not.
Returns:
NA
See also:
Example:
SupressFirst(Boolean $ft=true)
Parameters:
$ft TRUE/FALSE
Description:
Determine if the first tick mark should be displayed or not. It is sometimes useful to suppress the first tick mar if the labels from both scales gets very close to each other.
Returns:
NA
See also:
Example:
GetMajTickAbsSize()
Parameters:
NA
Description:
Get distance, in pixels, between Major tick marks.
Returns:
NA
See also:
Example:
Set(real $maj, real $min)
Parameters:
$maj Specify, in world coordinates, the distance between major tick marks
$min Specify, in world coordinates, the distance between minor tick marks
Description:
Specify where the major and minor tick marks should be.
Returns:
NA
See also:
Example:
SetPrecision(int $p)
Parameters:
$p Number of decimal points
Description:
Specify how many decimals should be displayed in the automatic labels
Returns:
NA
See also:
Example:
SetDirection(int $dir=1)
Parameters:
$dir -1 for left (or up), +1 for right (or down)
Description:
Specify if the tick marks should be to the left or right side for an Y-axis or on the up or down side for an X-axis.
Returns:
NA
See also:
SetDirection for class Axis which specifies which side the labels should go on.
Example:
function SetMarkColor($majcolor,$mincolor="")
Parameters:
$majcolor Color for major tick marks
$mincolor Color for minor tick marks
Description:
Specify color for major and minor tick marks
Returns:
NA
See also:
NA
Example:
$graph->yaxis->ticks->SetMarkColor(“black”,”blue”)
SetWeight($w)
Parameters:
$w Line weight for tick marks
Description:
Specify weight for tick marks (in pixels)
Returns:
NA
See also:
NA
Example:
$graph->yaxis->ticks->SetWeight(2);
Defined in file: jpgraph.php
Public
properties |
|
Public
methods |
Text() Hide() Center() SetFont() SetBox() SetOrientation() GetWidth() GetFontHeight() |
Private
properties & methods |
Stroke() |
General
description
Represents a text string which may be added to the graph area in an auxiliary position.
Text(String $txt="",real $x=0, real $y=0)
Parameters:
$txt Text string to display
$x X-position in percent (0,1) of image width. 0 percent is the left edge
$y Y-position in percent (0,1) of image width. 0 percent is the top edge
Description:
Creates a new text object which may be displayed anywhere within the image. The text object is then added to a specific graph through the AddText() method in the Graph class.
Returns:
NA
See also:
Example:
$t1 = new Text(“Overview”,0.30,0.80);
$graph->AddText($t1);
Set(String $t)
Parameters:
$t Text string
Description:
Set the text for a previous created Text object.
Returns:
NA
See also:
Example:
$t1->Set(“New title”);
SetBox(Mix $fcolor=array(255,255,255), Color $bcolor=array(0,0,0), $shadow=false)
Parameters:
$fcolor Box fill color, or FALSE if no box should be displayed
$bcolor Box frame color
$shadow Specifies if the box should have a drop shadow
Description:
Specifies that the text should be in a frame. If fill color is specified as “nofill” then the text will be framed but will not have a filled background.
Returns:
NA
See also:
Class Image :: StrokeBoxedText()
Example:
Pos(real $x=0, real $y=0,String $halign="left")
Parameters:
$x X-Coord in percent of image width
$y Y-Coord in percent of image width
$haling Horizontal alignment
Description:
Set position and specify alignment.
Returns:
NA
See also:
Class Image :: StrokeText()
Example:
Hide(Boolean $f=true)
Parameters:
$f TRUE/FALSE
Description:
Hide the text. The test will not be drawn.
Returns:
NA
See also:
Example:
SetFont(int $size, String $name="internal")
Parameters:
$size
$name
Description:
Specifies text font. See Image::SetFont() for a detailed description.
Returns:
NA
See also:
Example:
$t1->SetFont(FONT1_BOLD);
Center(int $left, int $right, Boolean Mixed $y=false)
Parameters:
$left Left x-coordinate
$right Left x-coordinate
$y If specified, the Y-coordinate
Description:
Center the text between the two X-coordinates using possible a previous specified Y-coordinate.
Returns:
NA
See also:
Pos()
Example:
SetColor(Color $color)
Parameters:
$color Color of text
Description:
Specify text color to be used.
Returns:
NA
See also:
Example:
$t1->SetColor(“navy”);
SetOrientation(String $d="horizontal")
Parameters:
$d Specify if the text should be drawn vertical or horizontal.
Description:
Set the orientation of the text, either vertical or horizontal.
Returns:
NA
See also:
Pos()
Example:
GetWidth(Class Image &$img)
Parameters:
$img The image we are drawing to
Description:
Returns the width, in pixels, of the text
Returns:
NA
See also:
Example:
GetFontHeight(Class Image &$img)
Parameters:
$img The image we are drawing to
Description:
Returns the height, in pixels, of the text
Returns:
NA
See also:
Example:
Stroke(Class Image &$img)
Parameters:
$img The image we are drawing to
Description:
Stroke the text to the specified image.
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Public
properties |
|
Public
methods |
SetLineStyle() Show() SetWeight() SetColor() SetWeight() |
Private
properties & methods |
Grid() Stroke() |
General
description
This class handles the drawing of the grid lines based on the calculations done by the Tick class which is responsible for determine the exact positions of each vertical or horizontal tick mark.
You normally manipulates the grid as an instance in the graph class, either as $graph->xgrid or as $graph->ygrid
Grid(Class Axis &$axis)
Parameters:
$axis Axis to which the grid lines belong
Description:
Handles the gridlines for the specified axis. Gridlines can be drawn on either just major ticks or on both major and minor ticks. The default is to draw grid liens on major ticks only.
Returns:
NA
See also:
Example:
SetWeight(int $weight)
Parameters:
$weight in pixels
Description:
Specify weight in pixels for the gridlines.
Returns:
NA
See also:
Example:
SetColor(Color $color)
Parameters:
$color
Description:
Specify color for gridlines. Default is a very light grey color.
Returns:
NA
See also:
Example:
SetLineStyle(String $type)
Parameters:
$type Type of gridlines, see below
Description:
Specify line style for gridlines. Allowed styles are
Deafult is “solid”.
Returns:
NA
See also:
Example:
Show(Boolean $major=true, Boolean $minor=false)
Parameters:
$major Show/Hide Major gridline
$minor Show/Hide Minor gridline
Description:
Determine what gridlines are visible. Default is to show only major gridlines.
Returns:
NA
See also:
Example:
$graph->ygrid(true,true); // Show both maj and minor gridmarks
Stroke()
Parameters:
NA
Description:
Draw the gridlines as previously specified. The gridlines will only be drawn within the plot area of the image. This is an internal method and should never be called from user level code.
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Extends Ticks.
|
|
LinearTicks |
Public
properties |
|
Public
properties |
Class LinearScale scale; Class Text title; |
|
|
Public
methods |
|
Public
methods |
SetColor() SetWeight() SetDirection()
|
|
SupressZeroLabel() SupressMinorTickMarks() SupressFirst() SetPrecision() GetMajor() GetMinor() Set() |
Private
properties & methods |
|
Private
properties & methods |
IsSpecified() Class Image
img; Ticks() GetMinTickAbsSize() GetMajTickAbsSize() |
|
LinearTicks() Stroke() SetXLabelOffset() SetTextLabelStart() |
General
description
The concrete class which implements linear ticks for X and Y axis. This class should be used through it’s instance as a property of the scale.
Instantiated
$grasph->xaxis->scale->ticks
LinearTicks()
Parameters:
NA
Description:
Create a new instance. Note this is a private method which should not be called by users of this library directly.
Returns:
NA
See also:
LogTicks()
Example:
GetMajor()
Parameters:
NA
Description:
Get major step size in world coordinates
Returns:
NA
See also:
GetMinor()
Example:
GetMinor()
Parameters:
NA
Description:
Get minor step size in world coordinates
Returns:
NA
See also:
Example:
Set(real $maj_step, real $min_step)
Parameters:
$maj_step Specify major step size in world coordinates
$min_step Specify minor step size in world coordinates
Description:
Set the step size to beused for minor and major ticks. Note you should normally let the autoscaling handle this since that is for most practical purposes good enough.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$scale, int $pos)
Parameters:
$img The image to be drawn to
$scale The scale associated with these ticks
$pos Determine which side of the axis the ticks should go on,allowed values are
-1 Left/Up
1 Right/Down
Description:
Stroke the tick marks to the image. This method is private to the library and should never be called directly.
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Public
properties |
Class Ticks ticks |
Public
methods |
GetMinVal() GetMaxVal() Update() Translate($a) SetColor() SetWeight() SetGrace() |
Private
properties & methods |
LinearScale() Init() IsSpecified() SetMin() AutoScale() CalcTicks() MatchMin3() InitConstants() Stroke() |
General
description
The general scale class which represent the scale on either a X or Y axis. If the scale is not explicitly set if will be automatically determined based on the min and max values of all the plots using this scale. Both X and Y axis may have a linear scale. A special version of the linear scale is the “text” scale which is a scale only containing whole numbers. Used to represent counting scales. A text scale may only be used for a X-axis.
LinearScale(real $min=0, real $max=0, String $type="y")
Parameters:
$min Minimum world value to be represented
$max Maximum world value to be represented
$type Determines if this is a X or Y axis
Description:
Create a new instance of a linear scale. This is a private method to the library and should as such never be called directly.
Returns:
NA
See also:
LogScale()
Example:
Init(Class Image &$img)
Parameters:
$img The image where the scale should be used
Description:
Second phase initialisation. Used to add the scale as an observer to the Image class since we need to get notified if the image changes it’s parameters, for example if the margin are changed we must recalculate our scaling constants.
Note this can’t be done in the constructor due to a bug in PHP4 that will not allow you to use a reference to “this” pointer in the constructor. Strictly speaking it will of course allow you to use it but it won’t work!
Internal method that should never be called by users of this library directly.
Returns:
NA
See also:
Image::AddNotifyer()
Example:
IsSpecified()
Parameters:
NA
Description:
Determine if the scale has been manually specified or not. Used to determine if the scale should be auto-scaled or not.
Returns:
TRUE/FALSE
See also:
Example:
SetAutoMin(real $min)
Parameters:
$min Min value in world coordinates for auto-scaling
Description:
By default the auto-scaling will use the lowest value of the plots as the minimum value of the Y-scale. If the chosen value falls “close to” 0. Then zero will be chosen. However, it is sometimes useful to hard set the minimum value used by the auto-scaling and then just have the auto-scaling determine the maximum (normally) Y-value.
This method allows you to do just that.
Returns:
NA
See also:
Example:
GetMinVal()
Parameters:
NA
Description:
Get the minimum world coordinate.
Returns:
NA
See also:
Example:
GetMaxVal()
Parameters:
NA
Description:
Get the maximum world coordinate.
Returns:
NA
See also:
Example:
Update(Class Image &$img, Real $min, Real $max)
Parameters:
$img Image where the scale is used
$min Minimum world coordinate
$max Maximum world coordinate
Description:
This method is really design as a the observer notification method. This will update internal constants that is used to perform the scaling between world and screen. This will get automatically called if, for example, the margins of the image are changed.
Note that this method should normally never be called directly by a user using this library.
Returns:
NA
See also:
Example:
Int Translate(Real $a)
Parameters:
$a World coordinate
Description:
Translates a given world coordinate to the corresponding screen pixel position within the image.
Returns:
Screen coordinate in pixels
See also:
NA
Example:
SetGrace($grace)
Parameters:
$a Grace factor
Description:
Adds $grace percent to the max and min values used for autoscaling ti make scale larger then the actual min and max values found in the data. The grace to add is calculated as the percentage of total dynamic range., i.e. (max-min) which is then added to the max value and subtracted from the mijn value to make the scale larger. A value of 10 normally gives satisfactory result. High values will make the graph look very compressed.
Returns:
NA
See also:
NA
Example:
$graph->yscale->SetGrace(10); // Set 10% grace value to Y-scale
AutoScale(Class Image &$img, Real $min, Real $max, int $maxsteps, Boolean $majend=true)
Parameters:
$img Image which is drawn to
$min Minimum world coordinate
$max Maximum world coordinate
$maxsteps Maximum number of major steps allowed
$majend Should the scale end at a major tick?
Description:
Performs autoscaling of the scale given the min/max and the number of maximum major ticks allowed. Note that the autoscaling algorithm will most likely adjust the minimum and maximum values to better fit within the scale chosen.
The maxsteps should in general be a function of the image size since a larger image can accommodate more ticks.
The autoscaling is quite smart in that it actually performs a small search among some standard scale step (multiple of 2, 5, 1 etc) to see which one fits best with the number of maximum steps. The autoscaling has a slight preference to steps of 5 (0.5, 0.05 etc) so if there is a close match the steps of 5’s will be chosen.
The end of the scale can finish either on a minor or major tick mark. If you want the scale to end on a major ticks mark, and hence have a potential label, the parameter $majend should be true.
Returns:
NA
See also:
CalcTicks()
Example:
InitConstants(Class &$img)
Parameters:
Img Image to draw top
Description:
Internal method. Initiates constants. Shuld never be called directly.
Returns:
NA
See also:
Example:
CalcTicks(int $maxsteps, Real $min, Real $max, int $a, int $b, Boolean $majend=true)
Parameters:
$maxsteps maximum number of major steps allowed on the scale
$min Min world coordinate
$max Max world coordinate
$a Algorithm Parameter a
$b Algorithm Parameter b
$majend Should the scale end on a major tick?
Description:
The internal work routine which tries to fit a number of ticks given the parameters a and b. The parameters will control what type of ticks we will be trying, steps of 2, 5 etc.
This is completely an internal routine and should never be called. Only documented for completeness.
Returns:
NA
See also:
AutoScale()
Example:
MatchMin3(int $a, int $b, int $c, Real $weight)
Parameters:
$a Value a
$b Value b
$c Value c
$weight Weight for value c
Description:
Performs a weighted 3 way minimum, i.e. find the minimum of the three values a,b,c. The weight is used to give the $c value a certain preference.
This is completely an internal routine and should never be called. Only documented for completeness.
Returns:
The minimum value
See also:
CalcTicks()
Example:
Defined in file: jpgraph.php
Extends Ticks.
|
|
LogTicks |
Public
properties |
|
Public
properties |
Class LinearScale scale; Class Text title; |
|
|
Public
methods |
|
Public
methods |
SetColor() SetWeight() SetDirection() Set() |
|
|
Private
properties & methods |
|
Private
properties & methods |
Class Image
img; Ticks() GetMinTickAbsSize() GetMajTickAbsSize() |
|
IsSpecified() LogTicks() Stroke() |
General
description
Calculates the tick marks for a logarithmic scale. This differs from the LinearTicks in that ticks can’t be set manually. They are always calculated to be on even logs.
LogTicks()
Parameters:
NA
Description:
Creates a new logarithmic tick
Returns:
NA
See also:
LinearScale
Example:
IsSpecified()
Parameters:
NA
Description:
Determines if the ticks has been manually specified or not.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img,Class LogScale &$scale, int $pos)
Parameters:
$img Image class to use
$scale logarithmic sacel to which the ticks belong
$pos Which side of the axis the ticks go, -1, 1
Description:
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Extends LinearScale.
|
|
LogScale |
Public
properties |
|
Public
properties |
Class Ticks ticks |
|
|
Public
methods |
|
Public
methods |
Update()
SetColor() SetWeight() |
|
Translate($a) GetMinVal() GetMaxVal() |
Private
properties & methods |
|
Private
properties & methods |
LinearScale() Init() IsSpecified() SetMin()
CalcTicks() MatchMin3() InitConstants() Stroke() |
|
LogScale() AutoScale() |
General
description
Represents a logarithmic scale. Note that plots which has an Y-value of 0 and is added to an Y axis with a logarithmic scale will be automatically adjusted to 1.
LogScale(int
$min, int $max, String $type="y")
Parameters:
$min Minimum value in whole number logs
$max Maximum value in whole number logs
$type X or Y axis
Description:
Creates a new logarithmic scale between the given limits. Note that the limits should be given in logs!
Returns:
NA
See also:
Example:
$l = new LogScale(0,2); // create a new Y scale between 1 and 100
int Translate(Real $a)
Parameters:
$a World coordinate to be translated
Description:
Translate a world coordinate to screen coordinate.
Returns:
Sceren coordinate
See also:
Example:
$pix = $scale->Translate(110,7);
Real GetMinVal()
Parameters:
NA
Description:
Get lowest value on scale
Returns:
Lowest value
See also:
LogScale::GetMaxVal()
Example:
Real GetMaxVal()
Parameters:
NA
Description:
Get highest value on scale
Returns:
Highest value
See also:
LogScale::GetMinVal()
Example:
AutoScale(Class Image &$img, Real $min, Real $max, int $maxsteps)
Parameters:
$img Drawing image
$min Min value of plots
$max Max value in plots
$maxsteps Maximum number of major steps
Description:
Determines the best fit log scale to accommodate both $min and $max values.
Notes this is an internal routine and should never be called directly by a user of this library.
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Public
properties |
|
Public
methods |
SetColor() Hide() SetShadow() SetLayout() SetFont() Pos() SetBackground() Add() |
Private
properties & methods |
Stroke() |
General
description
Defines the appearance of the legend box in the plot. The legend box contains all the legends specified for each plot in the graph. The legend box can have both horizontal and vertical layout.
Instantiated
$graph->legend
Legend()
Parameters:
NA
Description:
Create the legend. Note internal class should never be instantiated by a user class.
Returns:
NA
See also:
Example:
SetShadow(Boolean $f=true, int $width=2)
Parameters:
$f Shadow on/off
$width Shadow width
Description:
Specify if the legend box should have a drop shadow or not. Default is on.
Returns:
NA
See also:
Example:
SetLayout(int $l=LEGEND_VERT)
Parameters:
$l Determine horizontal or vertical layout
Description:
Determine if the text legend should be layout as stacked on top of each other (default) or horizontally beside each other. Legal values for $l are
Returns:
NA
See also:
Example:
SetFont(int $size, string $font="internal")
Parameters:
$font Font family
Description:
Specify font for legends. See section 5.2 for legal values of $size
Returns:
NA
See also:
Example:
Pos(Real $x, Real $y, String $halign="right", String $valign="top")
Parameters:
$x X-coordinate in percent of image width
$y X-coordinate in percent of image height
$haling How to interpret the X-coord
$valign How to interpret the Y-coord
Description:
Specify the position of the legend box.
Returns:
NA
See also:
Example:
SetBackground(Color $color)
Parameters:
$color Color
Description:
Specify background color for the legend box.
Returns:
NA
See also:
Example:
Add(String $txt, Color $color)
Parameters:
$txt Legend text to be added
$color Color of marker
Description:
Add a text legend to the legend box.
Note this is a private method that never should be called by a user libray directly. If you want a plot to have a legend use the SetLegend() method for that plot.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to be drawn to
$xscale X-scale used for graph
$yscale Y-scale used for graph
Description:
Stroke the legend to the graph.
Note internal routine and should never be directly called by a user of this library.
Returns:
NA
See also:
Example:
Defined in file: jpgraph_line.php
Extends Plot.
|
|
LinePlot |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
SetColor() SetLineWeight() Min() Max() SetLegend() |
|
LinePlot() SetFilled() SetFillColor() SetCenter() |
Private
properties & methods |
|
Private
properties & methods |
Plot()
PreStrokeAdjust() StrokeMargin() |
|
Legend() Stroke() |
General
description
The concrete class which implements a standard line plot.
LinePlot(Array Real &$datay, Mix $datax=false)
Parameters:
$datay Y-values
$datax Possible X-values
Description:
Create a line plot.
Returns:
NA
See also:
Example:
SetFilled(Boolean $f=true)
Parameters:
$f TRUE/FALSE
Description:
Determine if the line plot should be filled. The fill color is specified through the SetFillColor() method.
Returns:
NA
See also:
SetFillColor()
Example:
SetColor(Color $color)
Parameters:
$color Color
Description:
Specify line color.
Returns:
NA
See also:
SetFillColor()
Example:
SetFillColor(Color $color, Boolean $f=true)
Parameters:
$color Fill color
$f Should the line plot be filled ort not
Description:
Returns:
NA
See also:
Example:
Legend(Class Graph &$graph)
Parameters:
$graph Class Graph
Description:
Framework method. Gets called by framework to set the legend. Note if the plot is filled then the fill color will be used as the legend color, otherwise the line color will be used.
Internal method. Should never be called by a user of this library.
Returns:
NA
See also:
Example:
SetCenter($f=true)
Parameters:
$f Specify if x-scale ticks used with a “text” scale should be centered.
Description:
When using a text scale by default the first tick mark will coincide with the Y-axis and hence the first data point will have it’s x-coordinate the same as the Y-axis. This is not always aesthetic pleasing. To change this call SetCenter() this will make each tick-mark be placed in the center of it’s “tick-slot” and will have the effect of adding a vertical margin on the left and right of the plot-area.
See section “Advanced use of JpGraph – Using grace value” for an example.
Returns:
NA
See also:
NA
Example:
$lineplot->SetCenter()
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to draw to
$xscale X-Scale to use
$yscale Y-Scale to use
Description:
Stroke the line plot.
Internal method. Should never be called by a user of this library.
Returns:
NA
See also:
Example:
Defined in file: jpgraph_line.php
Extends Plot.
|
|
AccLinePlot |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
SetColor() SetLineWeight()
SetLegend() |
|
AccLinePlot() Max() Min() |
Private
properties & methods |
|
Private
properties & methods |
Plot()
PreStrokeAdjust() StrokeMargin() |
|
Legend() Stroke() |
General
description
The concrete class that implements an accumulated line plot. An accumulated line plot will “staple” each line plot on top of each other using each individual Y point as the distance to the previous line plot, hence the accumulation.
AccLinePlot(Array Class LinePlot $plots)
Parameters:
$plot Array of line plots
Description:
Creates a new accumulated line plot from two or more existing line plots
Returns:
NA
See also:
Example:
$l1=new LinePlot($data1y);
$l2=new LinePlot($data2y);
$l3=new LinePlot($data3y);
$al=new AccLinePlot( array($l1, $l2, $l3) );
Defined in file: jpgraph_line.php
Public
properties |
|
Public
methods |
PlotMark() SetType() SetColor() SetWidth() |
Private
properties & methods |
Stroke() |
General
description
This class encapsulates the functionality to draw and position Plot marks in a line or scatter graph. This is an internal class and should normally never be used. You should only access this class through the “mark” instance variable in the line and scatter plot.
Instantiated
$lineplot->mark
PlotMark()
Parameters:
NA
Description:
Create a new mark class.
Returns:
NA
See also:
Example:
SetType(int $t)
Parameters:
$t Specify mark type
Description:
Allowed types are:
· MARK_SQUARE, A filled square
· MARK_UTRIANGLE, A upward pointing triangle
· MARK_DTRIANGLE, A downward pointing triangle
· MARK_DIAMOND, A diamond shape
· MARK_CIRCLE, A non-filled circle.
· MARK_FILLEDCIRCLE, A filled circle
Returns:
NA
See also:
Example:
$lineplot->mark->SetType(MARK_DIAMOND);
SetColor(Color $color)
Parameters:
$color Color
Description:
Specify line color of marks
Returns:
NA
See also:
SetFillColor()
Example:
SetFillColor(Color $color)
Parameters:
$color Color
Description:
Specify fill color for marks
Returns:
NA
See also:
SetColor()
Example:
SetWidth(int $width)
Parameters:
$width Width, in pixels, of mark
Description:
Specify the width, in pixels, of the markl
Returns:
NA
See also:
SetColor()
Example:
Stroke(Class Image &$img, int $x, int $y)
Parameters:
$img Image to draw to
$x X-coordinate in pixels
$y Y-coordinate in pixels
Description:
Draw the mark to the specified image using the given screen coordinates (not world coordinates).
Returns:
NA
See also:
Example:
Defined in file: jpgraph_bar.php
Extends Plot.
|
|
BarPlot |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
SetColor() SetLineWeight()
Max() SetLegend() |
|
BarPlot() SetYStart() Min() SetWidth() SetFillColor() |
Private
properties & methods |
|
Private
properties & methods |
Plot()
StrokeMargin() |
|
Legend() Stroke() PreStrokeAdjust() |
General description
Concrete class which implements the standard vertical bar plot functionality.
BarPlot(Array Real &$datay)
Parameters:
$datay Datapoints
Description:
Create a new bar plot from the datapoint given in $datay
Returns:
NA
See also:
Example:
SetYStart(Real $y)
Parameters:
$y Start value in world coordinates
Description:
Sets the Y value to become the base of the bars. Normally this is set to 0. For logarithmic plots this is automatically adjusted to the lowest point on the scale.
Returns:
NA
See also:
Example:
SetWidth(Real $width)
Parameters:
$width In percent of major ticks (0.0-1.0)
Description:
Specify the width of each bar as percentage of with of the major ticks. This means that if you specify a width of 1.0 there will be no gaps between the bars
Returns:
NA
See also:
Example:
SetFillColor(Color $color)
Parameters:
$color Color
Description:
Set fill colors for bars.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to draw to
$xscale X-scale to be used
$yscale Y-scale to be used
Description:
Draw the bar plot to the specified image.
Returns:
NA
See also:
Example:
Defined in file: jpgraph_bar.php
Extends BarPlot.
|
|
GroupBarPlot |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
BarPlot() SetYStart()
SetWidth() SetFillColor() |
|
GroupBarPlot() Min() Max() |
Private
properties & methods |
|
Private
properties & methods |
PreStrokeAdjust() |
|
Legend() Stroke() |
General
description
Concrete class which is responsible for constricting a grouped bar plot out of two or more normal Bar Plot. Each bar in a group shares the same X-tick and the group bar is centred around that X-tick. Each bar within the group is given equal width.
GroupBarPlot(Array Class BarPlot $plots)
Parameters:
$plot Array of bar plots
Description:
Create a group bar plot from the given individual bar plots. Note that there should normally be the same number of data points for each bar plot.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to draw to
$xscale X-scale to be used
$yscale Y-scale to be used
Description:
Draw the group bar plot to the specified image.
Returns:
NA
See also:
Example:
Defined in file: jpgraph_bar.php
Extends BarPlot.
|
|
AccBarPlot |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
BarPlot() SetYStart()
SetWidth() SetFillColor() |
|
AccBarPlot() Min() Max() |
Private
properties & methods |
|
Private
properties & methods |
PreStrokeAdjust() |
|
Legend() Stroke() |
General
description
Implements accumulated bar plots, also known as stacked bar plots. Takes two or more normal bar plots and stacks them on top of each other for same X-values. Note the individual bars Y-values are treated as deltas, so for example if two bar plots are added and the first value of each bar is 2 and 3 the resulting stacked bar will have a value of (2+3)=5.
AccBarPlot(Array $plots)
Parameters:
$plot Array of bar plots
Description:
Create an accumulated bar graph plot from two or more other bar plots
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to draw to
$xscale X-scale to be used
$yscale Y-scale to be used
Description:
Draw the accumulated bar plot to the specified image.
Returns:
NA
See also:
Example:
Defined in file: jpgraph_error.php
Extends Plot.
|
|
ErrorPlot |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
SetColor() SetLineWeight()
Max() SetLegend() |
|
ErrorPlot() SetCenter() |
Private
properties & methods |
|
Private
properties & methods |
Plot()
StrokeMargin() |
|
Legend() Stroke() PreStrokeAdjust() |
General
description
Concrete class which implements error plots. Error plots takes two y-values for each X-value, min and max. It then marks each pair of min/max values with a vertical bar.
ErrorPlot(array &$datay, array $datax=false)
Parameters:
$datay Data points,contains 2-Y values for each X-point.
$datax If specified, used as X-coordinates
Description:
Create a new error plot.
Returns:
NA
See also:
Example:
SetCenter(Boolean $c=true)
Parameters:
$c Set center on/off
Description:
Specify if the data points should be place at the left end between each major tick or at the center of the major ticks.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to draw to
$xscale X-scale to be used
$yscale Y-scale to be used
Description:
Draw the error plot.
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Public properties |
|
Public methods |
SetColor() SetLineWeight() Min() Max() SetLegend() |
Private properties & methods |
Plot() Legend() Stroke() PreStrokeAdjust() StrokeMargin() |
General description
The abstract base class for all plots. All plots inherits from this class. Defines the basic characteristics of a plot.
Plot(Array real &$datay, Mix $datax=false)
Parameters:
$datay Y values o be plotted
$datax If specified used as X-coordinates.
Description:
Creates a new plot using the given data vectors. If no X-vector is given the data-points will be numbered sequentially starting with 0.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to use
$xscale X-scale to use for the plot
$yscale Y-scale to use for the plot
Description:
Stroke the plot.
Note internal routine and should never be directly called by a user of this library.
Returns:
NA
See also:
Example:
Legend(Class Graph &$graph)
Parameters:
$graph An instance of GRaph
Description:
Framework method. Gets called to let each individual plot decide what text should be added to the legend. The standard implementation just adds the legend property to the Legend() if the legend is non-empty. This will have a slight different implementation for plot types that manages several plots or several legends. In that case this routine should add each individual legend that should be shown to the $graph->legend.
Note internal routine and should never be directly called by a user of this library.
Returns:
NA
See also:
Example:
PreStrokeAdjust(Class Image &$graph)
Parameters:
$graph Instance of Graph()
Description:
Framework method. Gets called prior to tha stroking of the graph. May be used to make any adjustment to the scales (or ticks) that is needed. For example, in the BarPlot(), this is used to adjust the X-scale so that the bars gets ceneterd in the graph and not normally put close to the left Y-axis.
Note internal routine and should never be directly called by a user of this library.
Returns:
NA
See also:
Example:
SetWeight(int $weight)
Parameters:
$weight Specify weight of graph
Description:
Set the weight for the graph. The actual meaning of this method is determined by the concrete Plot class.
Returns:
NA
See also:
Example:
Min()
Parameters:
NA
Description:
Determine the minimum X and Y value of all points.
Returns:
NA
See also:
Max()
Example:
Max()
Parameters:
NA
Description:
Determine the maximum X and Y value of all points.
Returns:
NA
See also:
Min()
Example:
SetColor(Color $color)
Parameters:
$color Color
Description:
Specify color of the plot. This color will also be used in the legend box.
Returns:
NA
See also:
Example:
SetLegend(String $txt)
Parameters:
$txt Legend text
Description:
Specify legend text for the plot. Any specified text is then automatically added to the legend box.
Returns:
NA
See also:
Example:
SetLineWeight(int $weight=1)
Parameters:
$weight Line weight of the plot
Description:
Specify line weight of the graph. The actual meaning of this method is determined by the concrete Plot class.
Returns:
NA
See also:
Example:
StrokeMargin(Class Image &$img)
Parameters:
$img Image to be used
Description:
Framework method. Gets called after the margin in the graph has been set to its color. Should be used to draw anything in margin. The default implementation does nothing.
Returns:
NA
See also:
Example:
7.3.19 Class ErrorLinePlot
Defined in file: jpgraph_error.php
Extends ErrorPlot.
|
|
ErrorPlot |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
ErrorPlot() SetCenter() |
|
ErrorLinePlot() |
Private
properties & methods |
|
Private
properties & methods |
PreStrokeAdjust() |
|
Legend() Stroke() PreStrokeAdjust() |
General
description
The error line plot is much the same as the error plot with the addition of a line between the average value of each error plot pair. The properties of the line may be accessed through the ‘line’ property of the ErrLinePlot, so for example to draw a red line you issue the statement
$errlineplot->line->SetColor(“red”);
ErrorLinePlot(array &$datay, array $datax=false)
Parameters:
$datay Data points,contains 2-Y values for each X-point.
$datax If specified, used as X-coordinates
Description:
Create a new error line plot.
Returns:
NA
See also:
Example:
Stroke(Class Image &$img, Class LinearScale &$xscale, Class LinearScale &$yscale)
Parameters:
$img Image to draw to
$xscale X-scale to be used
$yscale Y-scale to be used
Description:
Draw the error line plot.
Returns:
NA
See also:
Example:
Defined in file: jpgraph_spider.php
Extends Graph
|
|
SpiderGraph |
Public
properties |
|
Public
properties |
Class Axis xaxis,yaxis,y2axis; Class Grid xgrid,ygrid,y2grid; Class Image img; Class Text title; |
|
Class SpiderAxis axis; Class SpiderGrid grid; |
Public
methods |
|
Public
methods |
AddText()
SetFrame() SetShadow()
|
|
SpiderGraph() SupressTickMarks() SetPlotSize() SetCenter() SetColor() SetTitles() SetTickDensity() Add() Stroke() |
Private
properties & methods |
|
Private
properties & methods |
Class LinearScale yscale;
StrokeFrame() |
|
|
General
description
Represent a spider graph. This differs from Graph in that it only contains one scale and one axis which is rotated in a number of copies around the center (set by SetCenter()). The number of axis is equal to the number of datapoints in the plot and hence the angle between each axis is 2*pi/ (nbr of datapoints). The firsr axis is orientated vertically at 90 degrees. Internally the $yscale instance variable is used for the scale of the axis.
SpiderGraph($width=300,$height=200,$cachedName="")
Parameters:
Width The width of the image used for the graph
Height The height of the image used for the graph
CachedName The name of the cached graphic file
Description:
Creates a new image readu for spider plots. If cachedname is given the normal JpGraph cache mechanism will kick in and save the generated image by that name. The next time the image is generated it will first try to locate a cached version of the same name if found it will read it directly from the cache, if not it will be generated.
Returns:
NA
See also:
Graph() Create a regular linear graph.
Example:
$graph = new SpiderGraph(300,200);
SupressTickMarks($f=true)
Parameters:
$f TRUE/FALSE Specify wether ot not tick marks should be shown.
Description:
Determine if tick marks should be displayed on each axis in the spider graph. The default is to turn the ticks off.
Returns:
NA
See also:
NA
Example:
$graph->SupressTickMarks();
SetPlotSize($size)
Parameters:
$size Set dimater of the spider plot in percentage.
Description:
Specifies the diameter of the spider plot in terms of min($wifth,$height) of the graph.
Returns:
NA
See also:
SetCenter()
Example:
$graph->SetPlotSize(0.7); // 70% of the minimum of width/height
SetCenter($px,$py=0.5)
Parameters:
$px Position in pixels of the center X-coordinate
$py Position in pixels of the center Y-coordinate
Description:
Specified the center of the spider plot graph in pixels, The default is to place the graph in the center of the image.
Returns:
NA
See also:
SetPlotSize()
Example:
SetColor($color)
Parameters:
$color Color for background in the graph
Description:
Specify the background color of the graph. The default is white.
Returns:
NA
See also:
NA
Example:
$graph->SetColor(“silver”);
SetTitles(array $title)
Parameters:
$title Array of titles for each axis.
Description:
Used to specify the title for each of the axis in the spider graph. The number of titles should match the number of data points in the plot (=number of axis in the graph).
Returns:
NA
See also:
NA
Example:
$graph->SetTitles(array(“Jan”,”Feb”,”Mar”,”Apr”,”May”,June”);
SetTickDensity($densy=TICKD_NORMAL)
Parameters:
$densy Tick density
Description:
Specify the tick density (i.e. how close should the tick marks / labels be on the axis). In spider graph only the vertical axis at 90 degrees have titles. The default setting is (of course) TICKD_NORMAL
Allowed setting are
Returns:
NA
See also:
NA
Example:
$graph->SetTickDensity(TICKD_SPARSE);
Add(&$splot)
Parameters:
$plot A new spider plot
Description:
Add a previously created spier plot to the spider graph. Note that each spider plot is stroked in the order it is added, i.e. the last plot added will go over previously added plots in terms of image depth.
Returns:
NA
See also:
Class SpiderPlot
Example:
$plot = SpiderPlot($data);
$graph->Add($plot);
GetPlotsYMinMax()
Parameters:
NA
Description:
Return the minimum and maximum value for all the plots in the graph.
Returns:
array($min,$max);
See also:
NA
Example:
NA
Stroke()
Parameters:
NA
Description:
Stroke the defined graph to an image. This call should be the last call in the script since this call will output the graph to the browser (and a cach file if a file name was specified when the graph was created).
Returns:
NA
See also:
SpiderGraph()
Example:
Trivial.
Defined in file: jpgraph_spider.php
Extends Axis
|
|
SpiderAxis |
Public
properties |
|
Public
properties |
Class LinearScale scale;
|
|
Class FontProp title |
Public
methods |
|
Public
methods |
Hide()
SetColor() SetWeight()
SetFont() |
|
SetTickLabels(); |
Private
properties & methods |
|
Private
properties & methods |
|
|
SpiderAxis() Stroke() |
General
description
Handles the axis in the spider graph. Note thaht even though this class inherits most of the methods from the general Axis class some methods are not supported since it is not suitable for this kind of axis. The striked through methods which doesn’t exist in class SpiderAxis are not supported.
SpiderAxis(&$img, &$scale, $color=array(0,0,0))
Parameters:
$img Image to be drawn to
$scale Scale to use
$color Color of axis and labels
Description:
Create a new spider axis. This is an internal (private) routine.
Returns:
NA
See also:
NA
Example:
NA
SetTickLabels($labels)
Parameters:
$labels Array of tick labels
Description:
Set the tick label array, i.e. the name of the tick labels. By default the normal value will be displayed to the right of the Y-axis.
Returns:
NA
See also:
NA
Example:
NA
Stroke($pos,$angle,&$grid,$title,$draw_label)
Parameters:
$pos Y-position inpixell of the axis start position
$angle Whiah angle dhould the axis be drawn at
$grid Output: Contains pair of pixel points for each of the grid points along the axis
$title Title of the axis
$draw_lable TRUE if the labels should be draw for this axis
Description:
Stroke the defined axis from the center at angle $angle to the image
Returns:
NA
See also:
NA
Example:
NA
Defined in file: jpgraph_spider.php
SpiderPlot |
Public
properties |
|
Public
methods |
SpiderPlot() Min() Max() SetLegend($legend) SetLineWeight() SetColor() |
Private properties
& methods |
GetCount() Legend() Stroke() |
General
description
Creates a new spider plot. Each spider plot can only be stroked to a SpiderGraph() throught the use of SpiderGraph::Add() method.
SpiderPlot($data)
Parameters:
$data Array of datapoints
Description:
Create a new spider plot from an array of data points. From each data point an axis is created. Note that for practical purposes the number of data points really should be less then 10-12 points. Otherwise the idea behind spier plots sorts of lose its meaning.
Returns:
NA
See also:
NA
Example:
$plot =
new SpiderPLot(array(12,36,42,55,19));
Min()
Parameters:
NA
Description:
Return the minimum value of all data points for this plot
Returns:
NA
See also:
Max()
Example:
$max = $plot->Min();
Max()
Parameters:
NA
Description:
Return the maximum value of all data points for this plot
Returns:
NA
See also:
Min()
Example:
$max = $plot->Max()
SetLegend($legend)
Parameters:
$legend Legend string
Description:
Specify legend for this plot. This is a text string that will be automatically added to the legend box.
Returns:
NA
See also:
NA
Example:
$plot->SetLegend(“Defect Goal”);
SetLineWeight($w)
Parameters:
$w Weight for plot lines in pixels.
Description:
Specify the weight (width) of the line in the spider plot.
Returns:
NA
See also:
NA
Example:
$plot->SetWeight(2); // Specify the weight to two pixels
SetColor($color,$fill_color=array(160,170,180))
Parameters:
$color Line Color
$fill_color Fill color
Description:
Specify the color of the spider plot.
Returns:
NA
See also:
NA
Example:
(Trivial.)
GetCount()
Parameters:
NA
Description:
Return number of datapoints in plot.
Returns:
Int NumberOfDataPoints
See also:
NA
Example:
(Trivial)
Legend(&$graph)
Parameters:
$graph An instance of the spider graph
Description:
This is a framework method that gest called in the SpiderGraph stroke() method. It is used to give each plot a chance to add the appropriate legend string and color to the legend I the graph. This helps the decoupling between the graph class and the plot class.
Returns:
NA
See also:
NA
Example:
NA
Stroke(&$img, $pos, &$scale, $startangle)
Parameters:
$img Image to stroke to
$pos Y-coordinate position for startpoint
$scale Scale to use
$startangle Startangle for first data point
Description:
Strokes the previously defined spider plot to the griven image. This is an internal method that will be called from SpiderGraph::Stroke()
Returns:
NA
See also:
NA
Example:
NA
Defined in file: jpgraph_spider.php
Extends Grid
|
|
SpiderGrid |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
SetLineStyle() Show() SetWeight() SetColor() SetWeight() |
|
|
Private
properties & methods |
|
Private
properties & methods |
|
|
SpiderGrid() |
General
description
Handles the drawing of grid lines in the spider graph. Inherits all standard properties from Grid()
SpiderGrid()
Parameters:
NA
Description:
Creates a new spider grid. This is internal grid that never should be called directly.
Returns:
NA
See also:
Grid()
Example:
NA
Defined in file: jpgraph_scatter.php
Extends Plot
|
|
SpiderGrid |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
|
|
|
Private
properties & methods |
|
Private properties
& methods |
|
|
|
General
description
ScatterPlot($datay,$datax)
Parameters:
$datay
$datax
Description:
Creates a new scatter plot from the coordinate arrays given.
Returns:
NA
See also:
Example:
Defined in file: jpgraph_spider.php
Extends Graph
|
|
SpiderGraph |
Public
properties |
|
Public
properties |
Class Image img; Class Text title; Class
Legend legend; |
|
|
Public
methods |
|
Public
methods |
AddText()
SetFrame() SetShadow()
|
|
Add() Stroke() |
Private
properties & methods |
|
Private
properties & methods |
Class LinearScale yscale;
StrokeFrame() |
|
|
General
description
Represent a spider graph. This differs from Graph in that it only contains one scale and one axis which is rotated in a number of copies around the center (set by SetCenter()). The number of axis is equal to the number of datapoints in the plot and hence the angle between each axis is 2*pi/ (nbr of datapoints). The firsr axis is orientated vertically at 90 degrees. Internally the $yscale instance variable is used for the scale of the axis.
PieGraph($width=300,$height=200,$cachedName="")
Parameters:
Width The width of the image used for the graph
Height The height of the image used for the graph
CachedName The name of the cached graphic file
Description:
Creates a new image ready for pie plots plots. If cachedname is given the normal JpGraph cache mechanism will kick in and save the generated image by that name. The next time the image is generated it will first try to locate a cached version of the same name if found it will read it directly from the cache, if not it will be generated.
Returns:
NA
See also:
Graph(), SpiderGraph()
Example:
$graph = new PieGraph(300,200);
Stroke()
Parameters:
NA
Description:
Sends the created image back to the browser. Should be the latest call in your script since script executionends with this call.
Returns:
NA
See also:
NA
Example:
$graph->Stroke();
Defined in file: jpgraph_pie.php
Extends --
SpiderGrid |
Public
properties |
Class Text title |
Public
methods |
PiePlot() SetCenter() SetSliceColors() SetStartAngle() SetFont() SetSize() SetFontColor() SetLegends() HideLabels() SetPrecision() |
Private
properties & methods |
Legend() Stroke() StrokeLabels() |
General
description
Creates a new Pie plot from the supplied data. By default each slice will have a label corresponding to the percentage of the sum it 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”)
PiePlot($datay)
Parameters:
$datay
Description:
Creates a new scatter plot from the coordinate arrays given.
Returns:
NA
See also:
Example:
SetCenter($x,$y=0.5)
Parameters:
$ Center y in percentage of height
$y Center x in percentage of width
Description:
Set the center for the pie plot. Default is to be in the center of the image.
Returns:
NA
See also:
SetSize()
Example:
$plot->SetCenter(0.3, 0.4);
SetSliceColors($color)
Parameters:
$color Array of colors to use
Description:
Set an array of colors to use for the different slices. If you have more slices than colors the colors will be rotated from beginning.
Returns:
NA
See also:
Example:
$plot->SetColors(array(“blue”,”green”,”red”,”orange”));
SetStartAngle($angle)
Parameters:
$angle Angle in radian (0<$angle<2*PI)
Description:
The first slice normally start at 0 degree. This method lets you specify at which angle the first slice should start. Note that the angle is specified in radians.
Returns:
NA
See also:
Example:
$plot->SetStartAngle(M_PI/4); // Start at 45 degree angle
SetFont($font_size, $font="internal")
Parameters:
$font_size Set Font size
$font Font type
Description:
Specify font for labels
Returns:
NA
See also:
Example:
$plot->SetFont(FONT1_BOLD);
SetSize($size)
Parameters:
$size Size in percentage of the minimum of the height or width
Description:
Set the radius of the pie plot in percentage of the minimum of the width and height of the image.
Returns:
NA
See also:
Example:
$plot->SetSize(0.3);
SetFontColor(Color $color)
Parameters:
$color Color
Description:
Specify color for labels on the pie plot
Returns:
NA
See also:
Example:
SetLegends(Array $legends)
Parameters:
$legends Array of legends for each pie slice
Description:
Returns:
NA
See also:
Example:
HideLabels(Boolean $f=true)
Parameters:
$f TRUE = Hide labels
Description:
Specify wheter or not labels should be displayed.
Returns:
NA
See also:
SetFontColor(), SetFont()
Example:
SetPrecision(int $prec, Boolean $psign=true)
Parameters:
$prec Number of digits precision for the labels of the pie plot
$psign TRUE if each label should have an ending ‘%’ sign
Description:
Specified to what precision the labels should be displayed..
Returns:
NA
See also:
NA
Example:
$p1->SetPrecision(2);
Stroke(&$img)
Parameters:
$img Image to stroke to.
Description:
Internal method should never be called directly. Stroke the pie plot to the specified image.
Returns:
NA
See also:
Example:
StrokeLabels($label,$img,$xc,$yc,$a,$r)
Parameters:
$label Text label to print
$img Image to print to
$xc X-coordinate for Center of pie chart
$yc Y-coordinate for Center of pie chart
$a Angle to plot label at
$r Radius of pie plot
Description:
Draws the labels for each slide. Normally the angle is choosen to be in the middle of the slice. Internal method and should never be called directly.
Returns:
NA
See also:
Example:
1.4 Internal class reference
Note: All the following classes are internal to JpGraph and should never be instantiated from clients to JpGraph. They are only documented for completeness and for those who whish to extend JpGraph.
Defined in file: jpgraph.php
Public properties |
|
Public methods |
ImgStreamCache() PutAndStream() GetAndStream() |
Private properties & methods |
|
General description
This is an internal class which is used by the Graph to handle streaming and caching of the generated image. This class should never be instantiated by a user of the library. It is only documented here for completeness.
ImgStreamCache(Class Image &$img, String $cacheDir=CACHE_DIR)
Parameters:
$img Image to be streamed
$cacheDir Cache directory to look for potentially cashed version of the image
Description:
Internal class to Image which handles the streaming and potential caching of images to file.
Returns:
NA
See also:
Example:
PutAndStream(Class Image &$img, String $fileName)
Parameters:
$img The image to stream
$filename Filename of cashed version
Description:
If filename is given then the image will be stored in the cache under that name. The image wil then be streamed back to the browser.
Note1 that this should be the last call since nothing else can be sent back to the browser after this call.
Note2 This is an internal method that never should be called directly by a user of this library.
Returns:
NA
See also:
Example:
GetAndStream(String $fileName)
Parameters:
$filename File name
Description:
Tries to find the file with specified name and then stream that file as
an image back to the browser.
Returns:
False if no file was found.
See also:
Example:
7.3.28 Class Image
Defined in file: jpgraph.php
Public
properties |
|
Public
methods |
AddObserver() SetFont() GetFontHeight() GetTextWidth() StrokeText() StrokeBoxedText() SetMargin() SetColor() SetTransparent() SetLineWeight() SetStartPoint() Line() LineTo() Arc() Polygon() FilledPolygon() Rectangle() FilledRectangle() ShadowRectangle() Point() DashedLine() SetImgFormat() SetLineStyle() StyleLine() |
Private properties
& methods |
Image() NotifyObservers() Headers() Stream() Destroy() |
General
description
Represent the lowest layer. Contains all the drawing primitives that directly generates an image.
Instantiated
$graph->img
Image(int $width, int $height, String $format="png")
Parameters:
$width Width in pixel of the generated image
$height Height in pixel of the generated image
$format Graphic format for the generated image
Description:
Creates a new image width the specified width and heigh. Depending on the value of $format three different graphic formats are supported
Note that the actual supported formats are dependent on the specific version of the GD library.To use jpg format and additional library must normally also be installed. See documentation on graphic formats in PHP manual.
Returns:
A handle to the newly created image
See also:
Example:
AddObserver(String $meth, Object &$obj)
Parameters:
$meth Name of method to be called
$obj The object where the method exists.
Description:
Adds an observer to the image class which gets called when basic values are changed, such as the margins of the image. The registred observer will be called with the a reference of the current instance of the Class Image
Returns:
NA
See also:
NotifyOnservers()
Example:
$img->AddObserver("InitConstants",&$this);
NotifyObservers()
Parameters:
NA
Description:
Calls all previously registered observers for this instance of Image. All the called observers will get called with a reference to the instance of this class as the first parameter.
This is really an internal method that never should be called. It is only described here for completeness.
Returns:
NA
See also:
AddObserver()
Example:
$img->NotifyObservers()
SetFont(int $size, String $name="internal")
Parameters:
$size Fontname/size
$name Type of font
Description:
Specify the font to be used for a successive call to StrokeFont(). Version 1.0 of JpGraph only supports internal fonts. The available internal fonts are specified with integers between 0-4 or with the symbolic constants according to the table
|
Font style |
|
Size |
Regular |
Bold |
Small |
FONT0 |
|
Normal |
FONT1 |
FONT1_BOLD |
Large |
FONT2 |
FONT2_BOLD |
Table 3. Available internal fonts.
Returns:
NA
See also:
StrokeFont(),
GetFontHeight(),GetFontWidth(),SetColor()
Example:
$graph->img->SetColor(“darkred”);
$graph->img->SetFont(FONT1_BOLD);
$graph->img->StrokeFont(50,20,”Revenue”,”center”);
GetFontHeight()
Parameters:
NA
Description:
Return the font height in pixels of the current active font.
Returns:
NA
See also:
GetTextWidth(), SetFont()
Example:
GetTextWidth(String &$txt)
Parameters:
$txt text string
Description:
Returns the width in pixel of the entire text string
supplied.
Returns:
Textwidth in pixels
See also:
SetFont()
Example:
StrokeText(int $x, int $y, String $txt, String $halign="left", String $dir="h")
Parameters:
$x Horizontal coordinate for text
$y Vertical coordinate for text
$txt Text to be stroked
$haling Horizontal alignment
$dir Direction (Horizontal or vertical)
Description:
Draws the specified text string at the specified position. Depending on the value of $haling the x-coordinate is interpret as:
$haling |
$x |
“Left”
|
Interpret as the left edge of the textstring |
“Center” |
Interpret as the center of the text string |
“Right”
|
Interpret as the right edge of the textstring |
Returns:
NA
See also:
SetFont(), GetFontHeight(), GetTextWidth()
Example:
$graph->img->StrokeText(50,20,”My first title”,”center”);
StrokeBoxedText(int $x, int $y, String $txt, String $halign, String $dir, Color $fcolor, Color $bcolor, Boolean $shadow=false)
Parameters:
$x Horizontal coordinate for text
$y Vertical coordinate for text
$txt Text to be stroked
$haling Horizontal alignment
$dir Direction (Horizontal or vertical)
$fcolor Fill color, if false no fill color will be used
$shadow TRUE if the box should have a drop shadow
Description:
Similar to StrokeText() but this method draws, a possible filled, box around the text. The box may also have a drop shadow.
Returns:
NA
See also:
SetFont(), GetFontHeight(), GetTextWidth(), StrokeText()
Example:
SetMargin(int $lm, int $rm, int $tm, int $bm)
Parameters:
$lm Left margin in pixels
$rm Right marging in pixels
$tm Top margin in pixels
$bm Bottom margin in pixels
Description:
Specifies the margin area between the plot-area and the end of the image. The margin should be big enough to hold any titles, labels or other text you want to be visible there.
Returns:
NA
See also:
Example:
$graph->img->SetMargin(20,20,30,30);
SetColor(Color $color)
Parameters:
$color Color
Description:
Specify drawing color for the following draw primitives. All consecutive calls to Line(), Rectangle(), Arc() etc. will be drawn using this color. A color may be specified either as the RGB-triple or as one of the predefined color names. Se chapter XX for a list of pre-defined color names.
Note. You should never call this function directly from user code since all defined drawing object (e.g. LinePlot()) have a SetColor() method which saves each objects own color which is then set (using this method) before the object is stroked to the image.
Returns:
NA
See also:
SetTransparent()
Example:
$graph->img->SetColor(“red”);
// or SetColor(array(255,0,0)) or SetColor(array(#FF,0,0))
$grph->img->Line(0,0,10,10);
SetTransparent(Color $color)
Parameters:
$color Transparent color
Description:
Specify which color should be transparent. Note that if you use a shadow on the image the upper right “non-shadow” and the lower left “non-shadow” will always default to color white. This means that if your page has a background you shold normally specify white as transparent to avoid a small white area at the corner of the shadow.
Returns:
NA
See also:
SetColor()
Example:
$graph->img->SetTRansparent(“white”);
SetLineWeight(int $weight))
Parameters:
$weight Line weight in pixels
Description:
Specify the line weight for Line(), LineTo() methods.
Note that the line weight will not be applied to Rectangle(), FilledRectangle(), Arc()
Returns:
NA
See also:
Example:
$img->SetLineWeight(2);
$img->Line(0,0,200,100);
SetStartPoint(int $x, int $y)
Parameters:
$x x-coordinate
$y y-coordinate
Description:
Specify a start x-y-point for the next LineTo() call.
Returns:
NA
See also:
LineTo()
Example:
$img->SetStartPoint(10,10);
$img->LineTo(100,100); //Draw a line between (10,10) and (100,100)
Arc(int $cx, int $cy, int $width, int $height, int $start, int $end)
Parameters:
$cx Center x-coordinate
$cy Center y-coordinate
$width Width of arc in pixels
$height Height of arc in pixels
$start Start angle (in degrees)
$end End angle (in degrees)
Description:
Draw an arc with the given coordinates and specifications.
Returns:
NA
See also:
Example:
$img->Arc(100,100,25,25,0,360); // Draw a circle width radius=25 pixels
Line(int $x1, int $y1, int $x2, int $y2)
Parameters:
$x1,$y1 Start point
$x2,$y2 End point
Description:
Draw a line between the specified coordinates.
Returns:
NA
See also:
SetLineWeight()
Example:
$img->Line(0,0,100,100);
Polygon(Array int $points)
Parameters:
$points Array of coordinates
Description:
Draws an polygon between all the data points specified in the array “$points”
Returns:
NA
See also:
SetColor(), FilledPolygon()
Example:
$pnts = array(0,0,10,15,12,15,12,30,40,30);
$img->Polygon($pnts);
FilledPolygon(Array int $points)
Parameters:
$points Array of coordinates
Description:
Draws a filled polygon between all the data points specified in the array “$points”
Returns:
NA
See also:
Polygon(), SetColor()
Example:
$pnts = array(0,0,10,15,12,15,12,30,40,30);
$img->FilledPolygon($pnts);
Rectangle(int $xl, int $yu, int $xr, int $yl)
Parameters:
$xl, $yu Upper left corner
$xr, $yl Lower right corner
Description:
Draw a rectangle
Returns:
NA
See also:
SetColor()
Example:
$img->Rectangle(20,10,50,60);
FilledRectangle(int $xl, int $yu, int $xr, int $yl)
Parameters:
$xl, $yu Upper left corner
$xr, $yl Lower right corner
Description:
Draw a filled rectangle
Returns:
NA
See also:
Rectangle()
Example:
$img->FilledRectangle(20,10,50,60);
ShadowRectangle(int $xl, int $yu, int $xr, int $yl, Boolean $fcolor=false, int $shadow_width=3, Color $shadow_color="gray40")
Parameters:
$xl, $yu Upper left corner
$xr, $yl Lower right corner
$fcolor Fill color of rectangle
$shadow_width Width of shadow
$shadow_color Color of shadow
Description:
Draws a filled rectangle with a shadow. If fcolor=false then no fill color will be used.
Returns:
NA
See also:
Rectangle(), Filledrectangle()
Example:
LineTo(int $x, int $y)
Parameters:
$x,$y End coordinate for the line
Description:
Draw a line between the previous end point for previous LineTo() to the point specified as parameter. The previous start point may also be specified with a call to SetStartPoint()
Returns:
NA
See also:
SetStartPoint()
Example:
Point(int $x, int $y)
Parameters:
$x,$y End coordinate for the line
Description:
Set a single pixel.
Returns:
NA
See also:
SetColor()
Example:
DashedLine(int $x1, int $y1, int $x2, int $y2, int $dash_length=1, int $dash_space=4)
Parameters:
$x1,$y1 Start point
$x2,$y2 End point
$dash_length Length, in pixel, of line segment
$dash_space Spec, inpixels, between line segments
Description:
Draws a dashed line with the specified parameters.
Note that this is a much more computationally expensive then drawing a straight line with either LineTo() or Line()
Returns:
NA
See also:
Line(), LineTo(), SetColor()
Example:
$img->DashedLine(0,0,30,50); // Draws a “dotted” line
Headers ()
Parameters:
NA
Description:
Internal method. Should never ever be called by a client.
Only documented for completeness.
Outputs the necessary headers to the browser in preparation to send the raw binary data that represents the image.
Implementation note: If you look at the implementation of Headers() you find that it is possible to output two versions of the header, one simple and one slightly more complicated. This is controlled by the instance variable $this->expired .
If this instance variable is true the header output will try to tell the browser not to cache the image, note that this is not foolproof since there is no standard way of guaranteeing the no-caching in browser.
The default value of $expired is TRUE.
Returns:
NA
See also:
Example:
Destroy()
Parameters:
NA
Description:
Returns resources allocated when the image was created.
Note. This is normally not used when generating on-line images but useful to free resources when images are just generated to files.
Returns:
NA
See also:
NA
Example:
Stream(Stream $file="")
Parameters:
$file File name to save image in
Description:
Streams the generated file either to a specified file (if parameter given) or directly back to the browser if no file name has been supplied.
Returns:
NA
See also:
Example:
$img->Stream(“exmaple1.png”); // Save the generated image in a file
SetImgFormat(String
$format)
Parameters:
$format Specifies graphic format
Description:
Specify the graphic format to be used.
This is a low level internal method. Should not be called directly. The graphic format is normally specified when creating an instance of the Image() class.
Allowed graphic formats are:
Returns:
TRUE If the graphic format is supported by the installation of PHP
FALSE Otherwise
See also:
Graph()
Example:
SetLineStyle($s)
Parameters:
$s line style
Description:
Specify a line style for subsequent calls to
StyleLine(). Allowed arguments are
Returns:
NA
See also:
Line()
Example:
StyleLine($x1,$y1,$x2,$y2)
Parameters:
$x1,$y1 Line Starting point
$x2,$y2 Line Ending
point
Description:
Same as a normal Line() but will also take
the current line style into account.
Returns:
NA
See also:
Line()
Example:
7.3.29 Class TTF
Defined in file: jpgraph.php
Extends --
TTF |
Public
properties |
|
Public
methods |
|
Private
properties & methods |
|
General
description
Handles loading of TTF font files and translation to specific TTF file names. This is an internal class and should never be used directly by clients to JpGraph library.
TTF()
Parameters:
NA
Description:
Initiates TTF fonts by setting the corresponfing file names.
Returns:
NA
See also:
Example:
MethodName()
Parameters:
Description:
Returns:
NA
See also:
Example:
7.3.30 Class Gradient
Defined in file: jpgraph_bar.php
Extends --
Gradient |
Public
properties |
|
Public
methods |
|
Private
properties & methods |
|
General
description
Handles all aspects of Color gradient fill. Internal class.
MethodName()
Parameters:
Description:
Returns:
NA
See also:
Example:
MethodName()
Parameters:
Description:
Returns:
NA
See also:
Example:
Defined in file: jpgraph.php
Public
properties |
|
Public
methods |
RGB() Color() Allocate() |
Private
properties & methods |
|
General
description
Defines symbolic color names and handles allocation of colors in the image. This is an internal class used by Image.
The following colors are predefined any other color can be specified by giving it’s RGB triple as the argument to any SetColor() method.
Table 4 . Predefined color names.
RGB(Class Image &$img)
Parameters:
$img Image where the colors should be allocated
Description:
Create a new instance of the color handling class.
Returns:
NA
See also:
Example:
Color(Mix $color)
Parameters:
$color Either a RGB triple or a color name as a string
Description:
Translates a color name to a RGB triple. If an RGB triple is passed through it is returned directly unless it is given in hex, in that case it is first translated to decimal
Returns:
An RGB triple
See also:
Example:
$c = RGB::Color(“#FFFFFF”);
// $c == array(255,255,255)
Allocate(Array $color)
Parameters:
$color Color given as either RGB triple, color name or hex-string
Description:
Allocates a new color in the image to which the RGB class belongs. Note that the very first color you allocate (index 0) will become the background color.
Returns:
Color index in image palette.
See also:
Example:
7.3.32 Class FontProp
Defined in file: jpgraph_spider.php
Extends --
FontProp |
Public
properties |
SetFont() SetColor() |
Public methods |
|
Private
properties & methods |
|
General
description
Internal class in spider used to enable the syntax $spider_plot->title->SetFont() by creating a sort of shadow class which is instantiated as poperty “title” in the spider plot.
SetFont($family,$style=FS_NORMAL,$size=12)
Parameters:
$family Font family
$style Font style
$size Font size
Description:
Specify font
Returns:
NA
See also:
NA
Example:
SetFont(FF_ARIAL,FS_NORMAL,12);
SetColor($color)
Parameters:
$color Named color or RGB array
Description:
Specify color
Returns:
NA
See also:
NA
Example:
SetColor(“gray2”);
7.3.33 Class RotImage
Defined in file: jpgraph.php
Extends Image
|
|
RotImage |
Public
properties |
|
Public
properties |
|
|
|
Public
methods |
|
Public
methods |
AddObserver() SetFont() GetFontHeight() GetTextWidth()
SetColor() SetMargin()
SetImgFormat() |
|
StrokeText() StrokeBoxedText() SetTransparent() SetLineWeight() SetStartPoint() Line() LineTo() Arc() Polygon() FilledPolygon() Rectangle() FilledRectangle() ShadowRectangle() Point() DashedLine() |
Private
properties & methods |
|
Private
properties & methods |
Image() NotifyObservers() Headers() Stream() Destroy() |
|
|
General
description
Exactly the same as Image but with the added twist that it rotateds the image Ñ degrees all the methods is exactly as in class Image().
RotImage($aWidth,$aHeight,$a,$aFormat=DEFAULT_GFORMAT)
Parameters:
$aWidth Image width in pixels
$aHeight Image height in pixels
$a Rotation angle
$aFormat Image format (encoding GIF, PNG, JPG)
Description:
Creates a RotImage class which implements the normal drawing primitives in Images but handles a rotation around (0,0) with a degree.
Returns:
NA
See also:
Image()
Example:
$img = RotImage(300,200,40,“png”);
7.3.34 Class ClassName
Defined in file: jpgraph.php
Extends --
ClassName |
Public
properties |
|
Public
methods |
|
Private
properties & methods |
|
General
description
MethodName()
Parameters:
Description:
Returns:
NA
See also:
Example:
MethodName()
Parameters:
Description:
Returns:
NA
See also:
Example:
7.3.35 Class ClassName
Defined in file: jpgraph.php
Extends --
ClassName |
Public
properties |
|
Public
methods |
|
Private
properties & methods |
|
General
description
MethodName()
Parameters:
Description:
Returns:
NA
See also:
Example:
MethodName()
Parameters:
Description:
Returns:
NA
See also:
Example: