Back to the module list

Graph the result of an array containing the data

Get the data from an array, a CSV, a JSON and draw it !

require_once ("domframework/graph.php");
$graph = new graph ();
// For CSV:
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1");
// For JSON:
$graph->data->json (json_encode (array (array ("T1","1","2","3","4"),
                                        array ("T2","5","6","7","8"))));
// For indexed array:
$graph->data->arrayIndexed (array (array ("T1","1","2","3","4"),
                                   array ("T2","5","6","7","8")));
// For associated array:
$graph->data->arrayAssociative (array (array ("t1"=>"11","t2"=>"12","t3"=>"13"),
                                       array ("t1"=>"21","t2"=>"22","t3"=>"23"),
                                       array ("t1"=>"31","t2"=>"32","t3"=>"33")));

$graph->drawImage();

The styles

The series can be drawn by different styles : line, linePoints, points.

$graph = new graph ();
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1")
            ->titlesOnFirstLine (true)
            ->titlesOnFirstColumn (true)
            ->horizontalData (true);
$graph->series->serie ("Return")->axisYsecondary(true);
$graph->drawImage ();

Line image

$graph = new graph ();
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1")
            ->titlesOnFirstLine (true)
            ->titlesOnFirstColumn (true)
            ->horizontalData (true);
$graph->series->serie ("Return")->axisYsecondary(true);
$graph->style ("linePoints");
$graph->drawImage ();

LinePoints image

$graph = new graph ();
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1")
            ->titlesOnFirstLine (true)
            ->titlesOnFirstColumn (true)
            ->horizontalData (true);
$graph->series->serie ("Return")->axisYsecondary(true);
$graph->style ("points");
$graph->drawImage ();

Points image

The integrated objects

The graph object carry some objects specialized in functions:

  • The graph object manage all the other ones. It allow to define the default style, the height and width of the drawn graph, the title position
    $graph->style ("linePoints")
          ->width (300)
          ->height (200);
  • The data object: manage the input of the data (from array, CSV, JSON). Allow to manage if there is a title on first line or column with autodetection. It also permit to say if the data are stored horizontally or vertically
  • The title object: manage the title of the graph, with font, size, color and text.
    $graph->title->text ("The SUPER Title")
                 ->color ("orange")
                 ->fontsize (10)
                 ->fontfile ("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf");
$graph = new graph ();
$graph->title->text ("The SUPER Title")
           ->color ("orange")
           ->fontsize (10)
           ->fontfile ("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf");
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1")
            ->titlesOnFirstLine (true)
            ->titlesOnFirstColumn (true)
            ->horizontalData (true);
$graph->series->serie ("Return")->axisYsecondary(true);
$graph->style ("points");
$graph->drawImage ();

Title image

  • The legend object: manage the display of a legend, with samples, series names, background-color, font and font size.
    $graph->legend->show (true);
$graph = new graph ();
$graph->title->text ("Display the legend")
           ->fontsize (10)
           ->fontfile ("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf");
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1")
            ->titlesOnFirstLine (true)
            ->titlesOnFirstColumn (true)
            ->horizontalData (true);
$graph->series->serie ("Return")->axisYsecondary(true);
$graph->style ("linePoints");
$graph->legend->show (true);
$graph->drawImage ();

Legende image

  • The series object manage the data series. It is an abstraction class.
  • The serie object, provided by the $graph->series->serie ("NAME"), allow to manage the serie. The serie can be drawn on the secondary axis, can have a maximum or minimum value, can have a style different of the general one defined in graph object. It allow to define if the provided data are numerical or labeled
    $graph->series->serie ("Return")->style ("line")
                                    ->axisYsecondary(true);
$graph = new graph ();
$graph->style ("linePoints");
$graph->title->text ("Default style in linePoints, one in line")
           ->fontsize (10)
           ->fontfile ("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf");
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1")
            ->titlesOnFirstLine (true)
            ->titlesOnFirstColumn (true)
            ->horizontalData (true);
$graph->series->serie ("Return")->axisYsecondary(true)->style("line");
$graph->drawImage ();

Serie image

  • The axis object allow to manage the colors, fonts (type and size). The objects defined can be used by $graph->axisX, $graph->axisY1 or $graph->axisY2
    $graph->axisY1->min (10)->max (300)->numerical (true);
    $graph->axisY2->min (-10)->max (10)->numerical (true);
    $graph->axisY1->gridColor ("blue");
    $graph->axisY2->gridColor ("blue");
    $graph->axisX->gridColor ("blue");
$graph = new graph ();
$graph->title->text ("Grids in blue color")
           ->fontsize (10)
           ->fontfile ("/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf");
$graph->data->csv ("\"\",Jan,Feb,Mar,Apr,May\n".
                 "Prod,200,210,NO,230,240\n".
                 "Return,5,4,3,2,1")
            ->titlesOnFirstLine (true)
            ->titlesOnFirstColumn (true)
            ->horizontalData (true);
$graph->series->serie ("Return")->axisYsecondary(true);
$graph->style ("points");
$graph->axisY1->min (10)->max (300)->numerical (true);
$graph->axisY2->min (-10)->max (10)->numerical (true);
$graph->axisY1->gridColor ("blue");
$graph->axisY2->gridColor ("blue");
$graph->axisX->gridColor ("blue");
$graph->drawImage ();

Axis image

The class definition

Class \graph

Namespace \

Description

 This class allow to generate an image which is a graphic. A graphic takes
 an array of values and draw the lines/histo... like a spreadsheet
 graph methods are :
   ->height ($height) or ->width ($width) The heigh/width of the graph

Properties

public $axisX;
 The X axis object
public $axisY1;
 The main Y axis object
public $axisY2;
 The optional secondary Y axis object
public $data;
 The data object
public $legend;
 The legend object
public $series;
 The series object
public $title;
 The graph title object

Methods

public function __construct ()
 Constructor : create the objects

public function bgcolor ($bgcolor=null)
 Set the background-color of the graph if the parameter is provided.
 Get the background-color of the graph if the parameter is not provided
 @param string|null $bgcolor The background-color of the graph

public function drawBase64 ()
 Return the image coded in base64
 @return string The base64 string

public function drawImage ()
 Draw the graph to the screen with the previous defined parameters

public function height ($height=null)
 Set the height of the graph if the parameter is provided.
 Get the height of the graph if the parameter is not provided
 @param integer|null $height The height of the graph

public function style ($style=null)
 Set the default style of the graph if the parameter is provided.
 Get the default style of the graph if the parameter is not provided
 @param string|null $style The style of the graph

public function titlePosition ($titlePosition=null)
 Set the title position of the graph if the parameter is provided.
 Get the title position of the graph if the parameter is not provided
 @param string|null $titlePosition The title position of the graph

public function width ($width=null)
 Set the width of the graph if the parameter is provided.
 Get the width of the graph if the parameter is not provided
 @param integer|null $width The width of the graph

Class \graphSeries

Namespace \

Description

 The series objects

Properties

No property available

Methods

public function getList ()
 Get the list of the defined series

public function remove ($name)
 Remove an existing serie
 @param string $name The name of the serie to remove

public function serie ($name)
 Return the serie object choosed. If doesn't exists, it is created before
 be returned
 @param string $name The name of the serie to create

Class \graphSerie

Namespace \

Description

 The serie object

Properties

No property available

Methods

public function __construct ($name)
 When creating the serie, save the name
 @param string $name The name of the serie

public function axisYsecondary ($axisYsecondary=null)
 The serie is based on the secondary Y axis
 Set the value if the parameter is provided, get the value if the parameter
 is not set
 @param boolean|null $axisYsecondary The Serie on secondary Y axis

public function count ()
 The number of elements in the serie

public function data ($data=null)
 Set the data for the serie
      If the parameter is not provided, return the actual $data value
 @param array|null $data The data to store in the serie

public function draw ($gd, $free, $axisX, $axisY)
 Draw the serie with the defined style class
 @param resource $gd The resource to modify
 @param array $free The free space coordinates on the graphic
 @param object $axisX The axis X used on the graph
 @param object $axisY The axis Y used on the graph

public function maxKey ()
 The maximum key of the serie

public function maxValue ()
 The maximum value of the serie

public function minKey ()
 The minimum key of the serie

public function minValue ()
 The minimum value of the serie

public function numericalKey ($numericalKey=null)
 Set/get the numeric key of the serie
 If the parameter is not provided, return the actual state
 @param boolean|null $numericalKey The state of the numeric key

public function numericalValue ($numericalValue=null)
 Set/get the numeric value of the serie
 If the parameter is not provided, return the actual state
 @param boolean|null $numericalValue The state of the numeric value

public function style ($style=null)
 Set/Get the graph style for the serie
 If the parameter is not provided, return the actual state
 @param string|object|null $style The graph style

Class \graphData

Namespace \

Description

 Read the data

Properties

No property available

Methods

public function arrayAssociative ($array)
 Get the data from an associative array
 The associative array are provided by database results
 @param array $array The data array to graph

public function arrayIndexed ($array)
 Get the data from an indexed array
 @param array $array The data array to graph

public function csv ($csv)
 Get the data from a CSV string
 @param string $csv The CSV string

public function getSeries ()
 Get the series in an array with the associated values

public function horizontalData ($horizontalData=null)
 The data are stored horizontally in the array
 Set the value if the parameter is provided, get the value if the parameter
 is not set
 @param boolean|null $horizontalData The data are stored horizontally

public function json ($json)
 Get the data from a JSON string
 @param string $json The JSON string

public function titlesOnFirstColumn ($titlesOnFirstColumn=null)
 Titles on first column
 Set the value if the parameter is provided, get the value if the parameter
 is not set
 @param boolean|null $titlesOnFirstColumn The titles on first column

public function titlesOnFirstLine ($titlesOnFirstLine=null)
 Titles on first line
 Set the value if the parameter is provided, get the value if the parameter
 is not set
 @param boolean|null $titlesOnFirstLine The titles on first line

Class \graphTitle

Namespace \

Description

 The graphTitle object

Properties

No property available

Methods

public function color ($color=null)
 Set the color of the title if the parameter is provided.
 Get the color of the title if the parameter is not provided
 @param string|null $color The color of the title

public function draw ($gd, $free)
 Draw the title in the $gd resource provided
 @param resource $gd The resource to modify
 @param array $free The free space coordinates on the graphic
 @return array the new free coordinates array

public function fontfile ($fontfile=null)
 Set the fontfile of the title if the parameter is provided.
 Get the fontfile of the title if the parameter is not provided
 @param string|null $fontfile The fontfile of the title

public function fontsize ($fontsize=null)
 Set the font size of the title if the parameter is provided.
 Get the font size of the title if the parameter is not provided
 @param integer|null $fontsize The font size of the title

public function padding ($padding=null)
 Set the padding of the title if the parameter is provided.
 Get the padding of the title if the parameter is not provided
 @param integer|null $padding The padding of the title

public function text ($text=null)
 Set the text of the title if the parameter is provided.
 Get the text of the title if the parameter is not provided
 @param string|null $text The text of the title

Class \graphLegend

Namespace \

Description

 The graphLegend object

Properties

No property available

Methods

public function bgcolor ($bgcolor=null)
 Set the background-color of the legend if the parameter is provided.
 Get the background-color of the legend if the parameter is not provided
 @param string|null $bgcolor The background-color of the legend

public function borderColor ($borderColor=null)
 Set the border color of the legend if the parameter is provided.
 Get the border color of the legend if the parameter is not provided
 @param string|null $borderColor The border color of the legend

public function color ($color=null)
 Set the color of the legend if the parameter is provided.
 Get the color of the legend if the parameter is not provided
 @param string|null $color The color of the legend

public function draw ($gd, $free, $series)
 Draw the legend in the $gd resource provided
 @param resource $gd The resource to modify
 @param array $free The free space coordinates on the graphic
 @param object $series The series to graph
 @return array the new free coordinates array

public function fontfile ($fontfile=null)
 Set the fontfile of the legend if the parameter is provided.
 Get the fontfile of the legend if the parameter is not provided
 @param string|null $fontfile The fontfile of the legend

public function fontsize ($fontsize=null)
 Set the font size of the legend if the parameter is provided.
 Get the font size of the legend if the parameter is not provided
 @param integer|null $fontsize The font size of the legend

public function padding ($padding=null)
 Set the padding of the legend if the parameter is provided.
 Get the padding of the legend if the parameter is not provided
 @param integer|null $padding The padding of the legend

public function show ($show=null)
 Set the legend display status if the parameter is provided.
 Get the legend display status if the parameter is not provided
 @param boolean|null $show The legend display status

Class \graphAxisGeneral

Namespace \

Description

 The general axis management

Properties

protected $axisColor;
 Axis color
protected $bottom;
 The minimum bottom position in pixels. Used on vertical axis
protected $data;
 The data displayed as values on the axis
protected $fontfile;
 The fontfile to write the labels
protected $fontsize=8;
 The fontsize to write the labels
protected $gridColor;
 Grid color on the axis
 Can be set to null or "transparent" to not display the grid
protected $labelMax;
 The label max to display
protected $labelMin;
 The label min to display
protected $left;
 The minimum left position in pixels. Used on horizontal axis
protected $max;
 The max value of the axis. Do not use it if the axis is composed of labels
protected $min;
 The min value of the axis. Do not use it if the axis is composed of labels
protected $numerical;
 Set if the axis is only numerical (true) or is composed of labels (false)
protected $right;
 The maximum right position in pixels. Used on horizontal axis
protected $top;
 The maximum top position in pixels. Used on vertical axis

Methods

public function axisColor ($axisColor=null)
 Set the axis color if the parameter is provided.
 Get the axis color if the parameter is not provided
 @param string|null $axisColor The axis color

public function bottom ($bottom=null)
 Set the bottom position of the axis if the parameter is provided.
 Get the bottom position of the axis if the parameter is not provided
 @param integer|null $bottom The bottom position of the axis

public function data ($data=null)
 Set the data of the axis if the parameter is provided.
 Get the data of the axis if the parameter is not provided
 @param array|null $data The data of the axis

public function fontfile ($fontfile=null)
 Set the fontfile of the labels if the parameter is provided.
 Get the fontfile of the labels if the parameter is not provided
 @param string|null $fontfile The fontfile of the title

public function fontsize ($fontsize=null)
 Set the font size of the labels if the parameter is provided.
 Get the font size of the labels if the parameter is not provided
 @param integer|null $fontsize The font size of the title

public function gridColor ($gridColor=null)
 Set the grid color if the parameter is provided.
 Get the grid color if the parameter is not provided
 @param string|null $gridColor The grid color

public function left ($left=null)
 Set the left position of the axis if the parameter is provided.
 Get the left position of the axis if the parameter is not provided
 @param integer|null $left The left position of the axis

public function max ($max=null)
 Set the max value of the axis if the parameter is provided.
 Get the max value of the axis if the parameter is not provided
 @param integer|null $max The max value of the axis

public function min ($min=null)
 Set the min value of the axis if the parameter is provided.
 Get the min value of the axis if the parameter is not provided
 @param integer|null $min The min value of the axis

public function numerical ($numerical=null)
 Set if the axis is numerical or composed of labels if the parameter is
 provided.
 Get if the axis is numerical if the parameter is not provided
 @param boolean|null $numerical the axis is numerical

public function right ($right=null)
 Set the right position of the axis if the parameter is provided.
 Get the right position of the axis if the parameter is not provided
 @param integer|null $right The right position of the axis

public function top ($top=null)
 Set the top position of the axis if the parameter is provided.
 Get the top position of the axis if the parameter is not provided
 @param integer|null $top The top position of the axis

protected function labels ($nbMaxValues)
 Calculate the labels that will be displayed on the axis
 @param integer $nbMaxValues The maximum number of values to return
 @return array The array of labels to display

Class \graphAxisHorizontal

Namespace \

Description

 The graph Axis Horizontal class

Properties

protected $axisColor;
 Axis color
protected $bottom;
 The minimum bottom position in pixels. Used on vertical axis
protected $data;
 The data displayed as values on the axis
protected $fontfile;
 The fontfile to write the labels
protected $fontsize=8;
 The fontsize to write the labels
protected $gridColor;
 Grid color on the axis
 Can be set to null or "transparent" to not display the grid
protected $labelMax;
 The label max to display
protected $labelMin;
 The label min to display
protected $left;
 The minimum left position in pixels. Used on horizontal axis
protected $max;
 The max value of the axis. Do not use it if the axis is composed of labels
protected $min;
 The min value of the axis. Do not use it if the axis is composed of labels
protected $numerical;
 Set if the axis is only numerical (true) or is composed of labels (false)
protected $right;
 The maximum right position in pixels. Used on horizontal axis
protected $top;
 The maximum top position in pixels. Used on vertical axis

Methods

public function axisColor ($axisColor=null)
 Set the axis color if the parameter is provided.
 Get the axis color if the parameter is not provided
 @param string|null $axisColor The axis color

public function bottom ($bottom=null)
 Set the bottom position of the axis if the parameter is provided.
 Get the bottom position of the axis if the parameter is not provided
 @param integer|null $bottom The bottom position of the axis

public function data ($data=null)
 Set the data of the axis if the parameter is provided.
 Get the data of the axis if the parameter is not provided
 @param array|null $data The data of the axis

public function fontfile ($fontfile=null)
 Set the fontfile of the labels if the parameter is provided.
 Get the fontfile of the labels if the parameter is not provided
 @param string|null $fontfile The fontfile of the title

public function fontsize ($fontsize=null)
 Set the font size of the labels if the parameter is provided.
 Get the font size of the labels if the parameter is not provided
 @param integer|null $fontsize The font size of the title

public function gridColor ($gridColor=null)
 Set the grid color if the parameter is provided.
 Get the grid color if the parameter is not provided
 @param string|null $gridColor The grid color

public function left ($left=null)
 Set the left position of the axis if the parameter is provided.
 Get the left position of the axis if the parameter is not provided
 @param integer|null $left The left position of the axis

public function max ($max=null)
 Set the max value of the axis if the parameter is provided.
 Get the max value of the axis if the parameter is not provided
 @param integer|null $max The max value of the axis

public function min ($min=null)
 Set the min value of the axis if the parameter is provided.
 Get the min value of the axis if the parameter is not provided
 @param integer|null $min The min value of the axis

public function numerical ($numerical=null)
 Set if the axis is numerical or composed of labels if the parameter is
 provided.
 Get if the axis is numerical if the parameter is not provided
 @param boolean|null $numerical the axis is numerical

public function position ($value)
 Calculate the position in pixels for a value
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMax ($value)
 Calculate the positionMax, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMin ($value)
 Calculate the positionMin, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function right ($right=null)
 Set the right position of the axis if the parameter is provided.
 Get the right position of the axis if the parameter is not provided
 @param integer|null $right The right position of the axis

public function top ($top=null)
 Set the top position of the axis if the parameter is provided.
 Get the top position of the axis if the parameter is not provided
 @param integer|null $top The top position of the axis

protected function labels ($nbMaxValues)
 Calculate the labels that will be displayed on the axis
 @param integer $nbMaxValues The maximum number of values to return
 @return array The array of labels to display

Class \graphAxisX

Namespace \

Description

 The X axis management

Properties

protected $axisColor;
 Axis color
protected $bottom;
 The minimum bottom position in pixels. Used on vertical axis
protected $data;
 The data displayed as values on the axis
protected $fontfile;
 The fontfile to write the labels
protected $fontsize=8;
 The fontsize to write the labels
protected $gridColor;
 Grid color on the axis
 Can be set to null or "transparent" to not display the grid
protected $labelMax;
 The label max to display
protected $labelMin;
 The label min to display
protected $left;
 The minimum left position in pixels. Used on horizontal axis
protected $max;
 The max value of the axis. Do not use it if the axis is composed of labels
protected $min;
 The min value of the axis. Do not use it if the axis is composed of labels
protected $nbcharsLabel=0;
 The number of chars to be displayed in one label
protected $numerical;
 Set if the axis is only numerical (true) or is composed of labels (false)
protected $right;
 The maximum right position in pixels. Used on horizontal axis
protected $top;
 The maximum top position in pixels. Used on vertical axis

Methods

public function axisColor ($axisColor=null)
 Set the axis color if the parameter is provided.
 Get the axis color if the parameter is not provided
 @param string|null $axisColor The axis color

public function bottom ($bottom=null)
 Set the bottom position of the axis if the parameter is provided.
 Get the bottom position of the axis if the parameter is not provided
 @param integer|null $bottom The bottom position of the axis

public function data ($data=null)
 Set the data of the axis if the parameter is provided.
 Get the data of the axis if the parameter is not provided
 @param array|null $data The data of the axis

public function draw ($gd)
 Draw the axis
 @param resource $gd The resource to modify

public function fontfile ($fontfile=null)
 Set the fontfile of the labels if the parameter is provided.
 Get the fontfile of the labels if the parameter is not provided
 @param string|null $fontfile The fontfile of the title

public function fontsize ($fontsize=null)
 Set the font size of the labels if the parameter is provided.
 Get the font size of the labels if the parameter is not provided
 @param integer|null $fontsize The font size of the title

public function getHeight ($gd)
 Look for the height of the X axis based on the angle of the text when it
 will be drawn
 @param resource $gd The resource to modify

public function gridColor ($gridColor=null)
 Set the grid color if the parameter is provided.
 Get the grid color if the parameter is not provided
 @param string|null $gridColor The grid color

public function left ($left=null)
 Set the left position of the axis if the parameter is provided.
 Get the left position of the axis if the parameter is not provided
 @param integer|null $left The left position of the axis

public function max ($max=null)
 Set the max value of the axis if the parameter is provided.
 Get the max value of the axis if the parameter is not provided
 @param integer|null $max The max value of the axis

public function min ($min=null)
 Set the min value of the axis if the parameter is provided.
 Get the min value of the axis if the parameter is not provided
 @param integer|null $min The min value of the axis

public function numerical ($numerical=null)
 Set if the axis is numerical or composed of labels if the parameter is
 provided.
 Get if the axis is numerical if the parameter is not provided
 @param boolean|null $numerical the axis is numerical

public function position ($value)
 Calculate the position in pixels for a value
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMax ($value)
 Calculate the positionMax, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMin ($value)
 Calculate the positionMin, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function right ($right=null)
 Set the right position of the axis if the parameter is provided.
 Get the right position of the axis if the parameter is not provided
 @param integer|null $right The right position of the axis

public function top ($top=null)
 Set the top position of the axis if the parameter is provided.
 Get the top position of the axis if the parameter is not provided
 @param integer|null $top The top position of the axis

protected function drawGrid ($gd, $width, $position)
 Draw the grid
 @param resource $gd The resource to modify
 @param integer $width The width of the labels on the axis
 @param integer|float $position The position to draw

protected function labels ($nbMaxValues)
 Calculate the labels that will be displayed on the axis
 @param integer $nbMaxValues The maximum number of values to return
 @return array The array of labels to display

Class \graphAxisVertical

Namespace \

Description

 Manage the vertical axis

Properties

protected $axisColor;
 Axis color
protected $bottom;
 The minimum bottom position in pixels. Used on vertical axis
protected $data;
 The data displayed as values on the axis
protected $fontfile;
 The fontfile to write the labels
protected $fontsize=8;
 The fontsize to write the labels
protected $gridColor;
 Grid color on the axis
 Can be set to null or "transparent" to not display the grid
protected $labelMax;
 The label max to display
protected $labelMin;
 The label min to display
protected $left;
 The minimum left position in pixels. Used on horizontal axis
protected $max;
 The max value of the axis. Do not use it if the axis is composed of labels
protected $min;
 The min value of the axis. Do not use it if the axis is composed of labels
protected $nbcharsLabel=0;
 The number of chars to be displayed in one label
protected $numerical;
 Set if the axis is only numerical (true) or is composed of labels (false)
protected $padding=7;
 The padding between the label and the axis
protected $right;
 The maximum right position in pixels. Used on horizontal axis
protected $top;
 The maximum top position in pixels. Used on vertical axis
protected $width;
 The width of the labels + padding (it is the base of the graph) in pixels

Methods

public function axisColor ($axisColor=null)
 Set the axis color if the parameter is provided.
 Get the axis color if the parameter is not provided
 @param string|null $axisColor The axis color

public function bottom ($bottom=null)
 Set the bottom position of the axis if the parameter is provided.
 Get the bottom position of the axis if the parameter is not provided
 @param integer|null $bottom The bottom position of the axis

public function data ($data=null)
 Set the data of the axis if the parameter is provided.
 Get the data of the axis if the parameter is not provided
 @param array|null $data The data of the axis

public function draw ($gd)
 Draw the axis labels and lines
 @param resource $gd The resource to modify

public function fontfile ($fontfile=null)
 Set the fontfile of the labels if the parameter is provided.
 Get the fontfile of the labels if the parameter is not provided
 @param string|null $fontfile The fontfile of the title

public function fontsize ($fontsize=null)
 Set the font size of the labels if the parameter is provided.
 Get the font size of the labels if the parameter is not provided
 @param integer|null $fontsize The font size of the title

public function getWidth ($gd)
 Look for the width of the Y axis
 @param resource $gd The resource to modify

public function gridColor ($gridColor=null)
 Set the grid color if the parameter is provided.
 Get the grid color if the parameter is not provided
 @param string|null $gridColor The grid color

public function left ($left=null)
 Set the left position of the axis if the parameter is provided.
 Get the left position of the axis if the parameter is not provided
 @param integer|null $left The left position of the axis

public function max ($max=null)
 Set the max value of the axis if the parameter is provided.
 Get the max value of the axis if the parameter is not provided
 @param integer|null $max The max value of the axis

public function min ($min=null)
 Set the min value of the axis if the parameter is provided.
 Get the min value of the axis if the parameter is not provided
 @param integer|null $min The min value of the axis

public function numerical ($numerical=null)
 Set if the axis is numerical or composed of labels if the parameter is
 provided.
 Get if the axis is numerical if the parameter is not provided
 @param boolean|null $numerical the axis is numerical

public function position ($value)
 Calculate the position in pixels for a value
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMax ($value)
 Calculate the positionMax, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMin ($value)
 Calculate the positionMin, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function right ($right=null)
 Set the right position of the axis if the parameter is provided.
 Get the right position of the axis if the parameter is not provided
 @param integer|null $right The right position of the axis

public function top ($top=null)
 Set the top position of the axis if the parameter is provided.
 Get the top position of the axis if the parameter is not provided
 @param integer|null $top The top position of the axis

protected function labels ($nbMaxValues)
 Calculate the labels that will be displayed on the axis
 @param integer $nbMaxValues The maximum number of values to return
 @return array The array of labels to display

Class \graphAxisY1

Namespace \

Description

 The Y1 axis management

Properties

protected $axisColor;
 Axis color
protected $bottom;
 The minimum bottom position in pixels. Used on vertical axis
protected $data;
 The data displayed as values on the axis
protected $fontfile;
 The fontfile to write the labels
protected $fontsize=8;
 The fontsize to write the labels
protected $gridColor;
 Grid color on the axis
 Can be set to null or "transparent" to not display the grid
protected $labelMax;
 The label max to display
protected $labelMin;
 The label min to display
protected $left;
 The minimum left position in pixels. Used on horizontal axis
protected $max;
 The max value of the axis. Do not use it if the axis is composed of labels
protected $min;
 The min value of the axis. Do not use it if the axis is composed of labels
protected $nbcharsLabel=0;
 The number of chars to be displayed in one label
protected $numerical;
 Set if the axis is only numerical (true) or is composed of labels (false)
protected $padding=7;
 The padding between the label and the axis
protected $right;
 The maximum right position in pixels. Used on horizontal axis
protected $top;
 The maximum top position in pixels. Used on vertical axis
protected $width;
 The width of the labels + padding (it is the base of the graph) in pixels

Methods

public function axisColor ($axisColor=null)
 Set the axis color if the parameter is provided.
 Get the axis color if the parameter is not provided
 @param string|null $axisColor The axis color

public function bottom ($bottom=null)
 Set the bottom position of the axis if the parameter is provided.
 Get the bottom position of the axis if the parameter is not provided
 @param integer|null $bottom The bottom position of the axis

public function data ($data=null)
 Set the data of the axis if the parameter is provided.
 Get the data of the axis if the parameter is not provided
 @param array|null $data The data of the axis

public function draw ($gd)
 Draw the axis labels and lines
 @param resource $gd The resource to modify

public function fontfile ($fontfile=null)
 Set the fontfile of the labels if the parameter is provided.
 Get the fontfile of the labels if the parameter is not provided
 @param string|null $fontfile The fontfile of the title

public function fontsize ($fontsize=null)
 Set the font size of the labels if the parameter is provided.
 Get the font size of the labels if the parameter is not provided
 @param integer|null $fontsize The font size of the title

public function getWidth ($gd)
 Look for the width of the Y axis
 @param resource $gd The resource to modify

public function gridColor ($gridColor=null)
 Set the grid color if the parameter is provided.
 Get the grid color if the parameter is not provided
 @param string|null $gridColor The grid color

public function left ($left=null)
 Set the left position of the axis if the parameter is provided.
 Get the left position of the axis if the parameter is not provided
 @param integer|null $left The left position of the axis

public function max ($max=null)
 Set the max value of the axis if the parameter is provided.
 Get the max value of the axis if the parameter is not provided
 @param integer|null $max The max value of the axis

public function min ($min=null)
 Set the min value of the axis if the parameter is provided.
 Get the min value of the axis if the parameter is not provided
 @param integer|null $min The min value of the axis

public function numerical ($numerical=null)
 Set if the axis is numerical or composed of labels if the parameter is
 provided.
 Get if the axis is numerical if the parameter is not provided
 @param boolean|null $numerical the axis is numerical

public function position ($value)
 Calculate the position in pixels for a value
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMax ($value)
 Calculate the positionMax, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMin ($value)
 Calculate the positionMin, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function right ($right=null)
 Set the right position of the axis if the parameter is provided.
 Get the right position of the axis if the parameter is not provided
 @param integer|null $right The right position of the axis

public function top ($top=null)
 Set the top position of the axis if the parameter is provided.
 Get the top position of the axis if the parameter is not provided
 @param integer|null $top The top position of the axis

protected function drawAxis ($gd, $width)
 Draw the axis
 @param resource $gd The resource to modify
 @param integer $width The width of the labels on the axis

protected function drawGrid ($gd, $width, $val)
 Draw the grid
 @param resource $gd The resource to modify
 @param integer $width The width of the labels on the axis
 @param integer|float $val The value to draw

protected function drawOne ($gd, $width, $val)
 Draw one value on the axis
 @param resource $gd The resource to modify
 @param integer $width The width of the labels on the axis
 @param integer|float $val The value to draw

protected function labels ($nbMaxValues)
 Calculate the labels that will be displayed on the axis
 @param integer $nbMaxValues The maximum number of values to return
 @return array The array of labels to display

Class \graphAxisY2

Namespace \

Description

 The Y2 axis management

Properties

protected $axisColor;
 Axis color
protected $bottom;
 The minimum bottom position in pixels. Used on vertical axis
protected $data;
 The data displayed as values on the axis
protected $fontfile;
 The fontfile to write the labels
protected $fontsize=8;
 The fontsize to write the labels
protected $gridColor;
 Grid color on the axis
 Can be set to null or "transparent" to not display the grid
protected $labelMax;
 The label max to display
protected $labelMin;
 The label min to display
protected $left;
 The minimum left position in pixels. Used on horizontal axis
protected $max;
 The max value of the axis. Do not use it if the axis is composed of labels
protected $min;
 The min value of the axis. Do not use it if the axis is composed of labels
protected $nbcharsLabel=0;
 The number of chars to be displayed in one label
protected $numerical;
 Set if the axis is only numerical (true) or is composed of labels (false)
protected $padding=7;
 The padding between the label and the axis
protected $right;
 The maximum right position in pixels. Used on horizontal axis
protected $top;
 The maximum top position in pixels. Used on vertical axis
protected $width;
 The width of the labels + padding (it is the base of the graph) in pixels

Methods

public function axisColor ($axisColor=null)
 Set the axis color if the parameter is provided.
 Get the axis color if the parameter is not provided
 @param string|null $axisColor The axis color

public function bottom ($bottom=null)
 Set the bottom position of the axis if the parameter is provided.
 Get the bottom position of the axis if the parameter is not provided
 @param integer|null $bottom The bottom position of the axis

public function data ($data=null)
 Set the data of the axis if the parameter is provided.
 Get the data of the axis if the parameter is not provided
 @param array|null $data The data of the axis

public function draw ($gd)
 Draw the axis labels and lines
 @param resource $gd The resource to modify

public function fontfile ($fontfile=null)
 Set the fontfile of the labels if the parameter is provided.
 Get the fontfile of the labels if the parameter is not provided
 @param string|null $fontfile The fontfile of the title

public function fontsize ($fontsize=null)
 Set the font size of the labels if the parameter is provided.
 Get the font size of the labels if the parameter is not provided
 @param integer|null $fontsize The font size of the title

public function getWidth ($gd)
 Look for the width of the Y axis
 @param resource $gd The resource to modify

public function gridColor ($gridColor=null)
 Set the grid color if the parameter is provided.
 Get the grid color if the parameter is not provided
 @param string|null $gridColor The grid color

public function left ($left=null)
 Set the left position of the axis if the parameter is provided.
 Get the left position of the axis if the parameter is not provided
 @param integer|null $left The left position of the axis

public function max ($max=null)
 Set the max value of the axis if the parameter is provided.
 Get the max value of the axis if the parameter is not provided
 @param integer|null $max The max value of the axis

public function min ($min=null)
 Set the min value of the axis if the parameter is provided.
 Get the min value of the axis if the parameter is not provided
 @param integer|null $min The min value of the axis

public function numerical ($numerical=null)
 Set if the axis is numerical or composed of labels if the parameter is
 provided.
 Get if the axis is numerical if the parameter is not provided
 @param boolean|null $numerical the axis is numerical

public function position ($value)
 Calculate the position in pixels for a value
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMax ($value)
 Calculate the positionMax, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function positionMin ($value)
 Calculate the positionMin, used for labeled axies
 If the value is out of range, return null to not draw the point
 @param string|float|integer $value The value to position

public function right ($right=null)
 Set the right position of the axis if the parameter is provided.
 Get the right position of the axis if the parameter is not provided
 @param integer|null $right The right position of the axis

public function top ($top=null)
 Set the top position of the axis if the parameter is provided.
 Get the top position of the axis if the parameter is not provided
 @param integer|null $top The top position of the axis

protected function drawAxis ($gd, $width)
 Draw the axis
 @param resource $gd The resource to modify
 @param integer $width The width of the labels on the axis

protected function drawGrid ($gd, $width, $val)
 Draw the grid
 @param resource $gd The resource to modify
 @param integer $width The width of the labels on the axis
 @param integer|float $val The value to draw

protected function drawOne ($gd, $width, $val)
 Draw one value on the axis
 @param resource $gd The resource to modify
 @param integer $width The width of the labels on the axis
 @param integer|float $val The value to draw

protected function labels ($nbMaxValues)
 Calculate the labels that will be displayed on the axis
 @param integer $nbMaxValues The maximum number of values to return
 @return array The array of labels to display

Class \graphStyleLinePoints

Namespace \

Description

 The graphStyleLine : draw a graph with lines

Properties

protected $allowedShapes=array (square,circle,triangle,lozenge);
 The allowed shapes
protected $lineColor;
 The line color. To hide the lines, choose "transparent"
protected $number;
 The number of the colors/shapes to use
protected $palette;
 The palette to use
protected $pointBgcolor;
 The point color background. To hide the points, choose "transparent"
protected $pointColor;
 The point color border
protected $pointShape;
 The point shape (square, circle, triangle, lozenge)
protected $pointWidth;
 The point width in pixel

Methods

public function draw ($gd, $free, $data, $axisX, $axisY)
 Draw in the $gd resource, in the $free array, the data with the parameter
 of the style
 @param resource $gd The resource to modify
 @param array $free The free space coordinates on the graphic
 @param array $data The data to graph
 @param object $axisX The X axis used to graph
 @param object $axisY The Y axis used to graph

public function lineColor ($lineColor=null)
 Set the line color if the parameter is provided.
 Get the line color if the parameter is not provided
 @param string|null $lineColor The line color

public function name ()
 Return the name of the style

public function number ($number=null)
 Select the colors, shapes by the serie number.
 Do not change any property if the property is already defined
 If the parameter is not provided, return the value
 @param integer|null $number The serie number

public function palette ($palette=null)
 Set the palette to use if the parameter is provided
 Get the palette if the parameter is not provided
 @param string|null $palette The palette to use

public function pointBgcolor ($pointBgcolor=null)
 Set the point background color if the parameter is provided.
 Get the point background color if the parameter is not provided
 @param string|null $pointBgcolor The point background color

public function pointColor ($pointColor=null)
 Set the point border color if the parameter is provided.
 Get the point border color if the parameter is not provided
 @param string|null $pointColor The point border color

public function pointShape ($pointShape=null)
 Set the point shape if the parameter is provided.
 Get the point shape if the parameter is not provided
 @param string|null $pointShape The point shape

public function pointWidth ($pointWidth=null)
 Set the point width if the parameter is provided.
 Get the point width if the parameter is not provided
 @param string|null $pointWidth The point width

public function sample ($gd, $x, $y)
 Draw a sample of the style for the legend
 @param resource $gd The resource to modify
 @param integer $x The central position of the sample in x
 @param integer $y The central position of the sample in y

Class \graphStylePoints

Namespace \

Description

 The graphStylePoints : draw a graph with points

Properties

protected $allowedShapes=array (square,circle,triangle,lozenge);
 The allowed shapes
protected $lineColor="transparent";
 The line color : transparent
protected $number;
 The number of the colors/shapes to use
protected $palette;
 The palette to use
protected $pointBgcolor;
 The point color background. To hide the points, choose "transparent"
protected $pointColor;
 The point color border
protected $pointShape;
 The point shape (square, circle, triangle, lozenge)
protected $pointWidth;
 The point width in pixel

Methods

public function draw ($gd, $free, $data, $axisX, $axisY)
 Draw in the $gd resource, in the $free array, the data with the parameter
 of the style
 @param resource $gd The resource to modify
 @param array $free The free space coordinates on the graphic
 @param array $data The data to graph
 @param object $axisX The X axis used to graph
 @param object $axisY The Y axis used to graph

public function lineColor ($lineColor=null)
 Set the line color if the parameter is provided.
 Get the line color if the parameter is not provided
 @param string|null $lineColor The line color

public function name ()
 Return the name of the style

public function number ($number=null)
 Select the colors, shapes by the serie number.
 Do not change any property if the property is already defined
 If the parameter is not provided, return the value
 @param integer|null $number The serie number

public function palette ($palette=null)
 Set the palette to use if the parameter is provided
 Get the palette if the parameter is not provided
 @param string|null $palette The palette to use

public function pointBgcolor ($pointBgcolor=null)
 Set the point background color if the parameter is provided.
 Get the point background color if the parameter is not provided
 @param string|null $pointBgcolor The point background color

public function pointColor ($pointColor=null)
 Set the point border color if the parameter is provided.
 Get the point border color if the parameter is not provided
 @param string|null $pointColor The point border color

public function pointShape ($pointShape=null)
 Set the point shape if the parameter is provided.
 Get the point shape if the parameter is not provided
 @param string|null $pointShape The point shape

public function pointWidth ($pointWidth=null)
 Set the point width if the parameter is provided.
 Get the point width if the parameter is not provided
 @param string|null $pointWidth The point width

public function sample ($gd, $x, $y)
 Draw a sample of the style for the legend
 @param resource $gd The resource to modify
 @param integer $x The central position of the sample in x
 @param integer $y The central position of the sample in y

Class \graphStyleLine

Namespace \

Description

 The graphStyleLine : draw a graph with line

Properties

protected $allowedShapes=array (square,circle,triangle,lozenge);
 The allowed shapes
protected $lineColor;
 The line color. To hide the lines, choose "transparent"
protected $number;
 The number of the colors/shapes to use
protected $palette;
 The palette to use
protected $pointBgcolor="transparent";
 The point color background. To hide the points, choose "transparent"
protected $pointColor="transparent";
 The point color border
protected $pointShape;
 The point shape (square, circle, triangle, lozenge)
protected $pointWidth;
 The point width in pixel

Methods

public function draw ($gd, $free, $data, $axisX, $axisY)
 Draw in the $gd resource, in the $free array, the data with the parameter
 of the style
 @param resource $gd The resource to modify
 @param array $free The free space coordinates on the graphic
 @param array $data The data to graph
 @param object $axisX The X axis used to graph
 @param object $axisY The Y axis used to graph

public function lineColor ($lineColor=null)
 Set the line color if the parameter is provided.
 Get the line color if the parameter is not provided
 @param string|null $lineColor The line color

public function name ()
 Return the name of the style

public function number ($number=null)
 Select the colors, shapes by the serie number.
 Do not change any property if the property is already defined
 If the parameter is not provided, return the value
 @param integer|null $number The serie number

public function palette ($palette=null)
 Set the palette to use if the parameter is provided
 Get the palette if the parameter is not provided
 @param string|null $palette The palette to use

public function pointBgcolor ($pointBgcolor=null)
 Set the point background color if the parameter is provided.
 Get the point background color if the parameter is not provided
 @param string|null $pointBgcolor The point background color

public function pointColor ($pointColor=null)
 Set the point border color if the parameter is provided.
 Get the point border color if the parameter is not provided
 @param string|null $pointColor The point border color

public function pointShape ($pointShape=null)
 Set the point shape if the parameter is provided.
 Get the point shape if the parameter is not provided
 @param string|null $pointShape The point shape

public function pointWidth ($pointWidth=null)
 Set the point width if the parameter is provided.
 Get the point width if the parameter is not provided
 @param string|null $pointWidth The point width

public function sample ($gd, $x, $y)
 Draw a sample of the style for the legend
 @param resource $gd The resource to modify
 @param integer $x The central position of the sample in x
 @param integer $y The central position of the sample in y

Class \graphPalette

Namespace \

Description

 The graphPalette class

Properties

No property available

Methods

static public function getPalette ($name)
 Get the complete palette
 @param string $name The palette name to get