apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: Image_Graph

Source Location: /Image_Graph-0.3.0dev1/Graph.php

Class Overview

Image_Graph_Common
   |
   --Image_Graph_Element
      |
      --Image_Graph

Main class for the graph creation.


Methods


Child classes:

Image_Graph_Simple
Class for simple creation of graphs

Inherited Variables

Inherited Methods

Class: Image_Graph_Element

Image_Graph_Element::height()
The height of the element on the canvas
Image_Graph_Element::setBackground()
Sets the background fill style of the element
Image_Graph_Element::setBackgroundColor()
Sets the background color of the element
Image_Graph_Element::setBorderColor()
Sets the border color of the element
Image_Graph_Element::setBorderStyle()
Sets the border line style of the element
Image_Graph_Element::setFillColor()
Sets the fill color of the element
Image_Graph_Element::setFillStyle()
Sets the fill style of the element
Image_Graph_Element::setFont()
Sets the font of the element
Image_Graph_Element::setLineColor()
Sets the line color of the element
Image_Graph_Element::setLineStyle()
Sets the line style of the element
Image_Graph_Element::setPadding()
Sets padding of the element
Image_Graph_Element::showShadow()
Shows shadow on the element
Image_Graph_Element::width()
The width of the element on the canvas
Image_Graph_Element::write()
Writes text to the canvas.

Class: Image_Graph_Common

Image_Graph_Common::Image_Graph_Common()
Constructor
Image_Graph_Common::add()
Adds an element to the objects element list, the new Image_Graph_elements parent is automatically set
Image_Graph_Common::addNew()
Creates an object from the class specified and adds it to the objects element list.

Class Details

[line 65]
Main class for the graph creation.

This is the main class, it holds the canvas and performs the final output by sending the http headers and making sure the elements are outputted.



[ Top ]


Method Detail

Image_Graph (Constructor)   [line 172]

Image_Graph &Image_Graph( mixed $params, [int $height = false], [bool $createTransparent = false])

Image_Graph [Constructor].

If passing an array as a single parameter, the following set of indexes can be used: 1) Create a new image 'width' - The width of the graph in pixels 'height' - The height of the graph in pixels 'transparent' - If set the graph is created with a transparent background 2) Use an "existing" GD image 'image' - A gd resource to add the graph to 'left' - The left most pixel where the graphs starts on the image 'top' - The top most pixel where the graph starts on the image 'width' and 'height' as above 3) Create from a file 'filename' - The filename of the image to add the graph to (either PNG or JPEG) 'left', 'top', 'width' and 'height' as above


Parameters:

mixed   $params   —  A set of parameters in an indexed array or the width of the graph in pixels.
int   $height   —  The height of the graph in pixels
bool   $createTransparent   —  Specify whether

[ Top ]

antialias   [line 449]

void antialias( [int $percent = 5])

Antialias on the graph

Parameters:

int   $percent   —  The percentage 'to' antialias

[ Top ]

cache   [line 717]

void cache( [string $cacheDir = 'cache/'])

Enable caching of the output.

Note! Any change at all to any part of the graph makes it output again. Do *NOT* use caching with plots using Image_Graph_Dataset_Random. The specified cache directory must exist prior to caching. Requires PEAR::Cache.


Parameters:

string   $cacheDir   —  The directory where cached files are put. If false caching is disabled.

[ Top ]

displayErrors   [line 457]

void displayErrors( )

Displays errors on canvas

[ Top ]

done   [line 468]

mixed done( [int $type = IMG_PNG])

Output to the canvas
  • Return: If the scripts outputs the image to the browser true is returned, if no output, the GD image is returned

Parameters:

int   $type   —  The type of image to output, i.e. IMG_PNG (default) and IMG_JPEG

[ Top ]

factory   [line 506]

object A &factory( string $class, [mixed $params = null])

Factory method to create Image_Graph objects.

Used for 'lazy including', i.e. loading only what is necessary, when it is necessary. If only one parameter is required for the constructor of the class simply pass this parameter as the $params parameter, unless the parameter is an array or a reference to a value, in that case you must 'enclose' the parameter in an array. Similar if the constructor takes more than one parameter specify the parameters in an array, i.e Image_Graph::factory('MyClass', array($param1, $param2, &$param3));

Class name can be either of the following:

  1. The 'real' Image_Graph class name, i.e. Image_Graph_Plotarea or Image_Graph_Plot_Line
  2. Short class name (leave out Image_Graph) and retain case, i.e. Plotarea, Plot_Line *not* plot_line
  3. Class name alias, the following are supported:
'graph' = Image_Graph 'plotarea' = Image_Graph_Plotarea 'line' = Image_Graph_Plot_Line 'area' = Image_Graph_Plot_Area 'bar' = Image_Graph_Plot_Bar 'stacked_bar' = Image_Graph_Plot_Bar_Stacked 'dataset' = Image_Graph_Dataset_Trivial 'random' = Image_Graph_Dataset_Random 'axis' = Image_Graph_Axis 'axis_log' = Image_Graph_Axis_Logarithmic 'title' = Image_Graph_Title 'line_grid' = Image_Graph_Grid_Lines 'bar_grid' = Image_Graph_Grid_Bars 'legend' = Image_Graph_Legend 'ttf_font' = Image_Graph_Font_TTF 'gradient' = Image_Graph_Fill_Gradient

  • Return: new object for the class

Overridden in child classes as:

Image_Graph_Simple::factory()
Factory method to create the Image_Simple_Graph object.

Parameters:

string   $class   —  The class for the object
mixed   $params   —  The paramaters to pass to the constructor

[ Top ]

height   [line 323]

int height( )

The height of the graph
  • Return: Number of pixels representing the height of the graph

Overrides Image_Graph_Element::height() (The height of the element on the canvas)
[ Top ]

hideLogo   [line 282]

void hideLogo( )

Hides the logo from the output

[ Top ]

horizontal   [line 578]

void &horizontal( &$part1, &$part2, [int $percentage = 50], Image_Graph_Element $part1, Image_Graph_Element $part2)

Factory method to create horizontal layout.

Parameters:

Image_Graph_Element   $part1   —  The 1st part of the layout
Image_Graph_Element   $part2   —  The 2nd part of the layout
int   $percentage   —  The percentage of the layout to split at
   &$part1   — 
   &$part2   — 

[ Top ]

layoutFactory   [line 566]

void &layoutFactory( mixed $layout, &$part1, &$part2, [int $percentage = 50], Image_Graph_Element $part1, Image_Graph_Element $part2)

Factory method to create layouts.

This method is used for easy creation, since using {@see Image_Graph::factory()} does not work with passing newly created objects from Image_Graph::factory() as reference, this is something that is fortunately fixed in PHP5. Also used for 'lazy including', i.e. loading only what is necessary, when it is necessary.


Parameters:

mixed   $layout   —  The type of layout, can be either 'Vertical' or 'Horizontal'
Image_Graph_Element   $part1   —  The 1st part of the layout
Image_Graph_Element   $part2   —  The 2nd part of the layout
int   $percentage   —  The percentage of the layout to split at
   &$part1   — 
   &$part2   — 

[ Top ]

newColor   [line 295]

void newColor( int $red, [int $green = false], [int $blue = false], [int $alpha = false])

Get a new color.

This method allocates a color to the graph. {@see Image_Graph_Color::allocateColor()}.


Parameters:

int   $red   —  The red part or the whole part
int   $green   —  The green part (or nothing), or the alpha channel
int   $blue   —  The blue part (or nothing)
int   $alpha   —  The alpha channel (or nothing)

[ Top ]

rotate   [line 332]

void rotate( $rotation, int $Rotation)

Rotate the final graph

Parameters:

int   $Rotation   —  Number of degrees to rotate the canvas counter-clockwise
   $rotation   — 

[ Top ]

saveAs   [line 364]

void saveAs( string $fileName, [bool $outputImage = false])

Save the output as a file

Parameters:

string   $fileName   —  The filename and path of the file to save output in
bool   $outputImage   —  Output the image to the browser as well

[ Top ]

thumbnail   [line 376]

void thumbnail( [int $width = 80], [int $height = 60], [string $fileName = ''])

Create the output as a thumbnail

Parameters:

int   $width   —  The width of the thumbnail
int   $height   —  The height of the thumbnail
string   $fileName   —  The filename and path of the file to save the thumbnail in, if specified the thumbnail will be saved and the output will be the normal graph

[ Top ]

vertical   [line 588]

void &vertical( &$part1, &$part2, [int $percentage = 50], Image_Graph_Element $part1, Image_Graph_Element $part2)

Factory method to create vertical layout.

Parameters:

Image_Graph_Element   $part1   —  The 1st part of the layout
Image_Graph_Element   $part2   —  The 2nd part of the layout
int   $percentage   —  The percentage of the layout to split at
   &$part1   — 
   &$part2   — 

[ Top ]

width   [line 314]

int width( )

The width of the graph
  • Return: Number of pixels representing the width of the graph

Overrides Image_Graph_Element::width() (The width of the element on the canvas)
[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:57:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.