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

Class: Image_Graph

Source Location: /Image_Graph-0.8.0/Graph.php

Class Overview

Image_Graph_Common
   |
   --Image_Graph_Element
      |
      --Image_Graph

Main class for the graph creation.


Author(s):

Version:

  • Release: 0.8.0

Copyright:

  • 2003-2009 The PHP Group

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::setFontAngle()
Sets the font angle
Image_Graph_Element::setFontColor()
Sets the font color
Image_Graph_Element::setFontSize()
Sets the font size
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.
Image_Graph_Element::_clip()
Clip the canvas to the coordinates of the element

Class: Image_Graph_Common

Image_Graph_Common::Image_Graph_Common()
Constructor [Image_Graph_Common]
Image_Graph_Common::add()
Adds an element to the objects element list.
Image_Graph_Common::addNew()
Creates an object from the class and adds it to the objects element list.
Image_Graph_Common::hide()
Hide the element

Class Details

[line 68]
Main class for the graph creation.

This is the main class, it manages the canvas and performs the final output by sequentialy making the elements output their results. The final output is handled using the Image_Canvas classes which makes it possible to use different engines (fx GD, PDFlib, libswf, etc) for output to several formats with a non-intersecting API.

This class also handles coordinates and the correct managment of setting the correct coordinates on child elements.



[ Top ]


Method Detail

Image_Graph (Constructor)   [line 136]

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

Image_Graph [Constructor].

If passing the 3 parameters they are defined as follows:'

Fx.:

$Graph = new Image_Graph(400, 300);

or using the factory method:

$Graph =& Image_Graph::factory('graph', array(400, 300));

This causes a 'png' canvas to be created by default.

Otherwise use a single parameter either as an associated array or passing the canvas along to the constructor:

1) Create a new canvas with the following parameters:

'canvas' - The canvas type, can be any of 'gd', 'jpg', 'png' or 'svg' (more to come) - if omitted the default is 'gd'

'width' - The width of the graph

'height' - The height of the graph

An example of this usage:

$Graph =& Image_Graph::factory('graph', array(array('width' => 400, 'height' => 300, 'canvas' => 'jpg')));

NB! In th�s case remember the "double" array (see Image_Graph::)

2) Use the canvas specified, pass a valid Image_Canvas as parameter. Remember to pass by reference, i. e. &$canvas, fx.:

$Graph = new Image_Graph($Canvas);

or using the factory method:

$Graph =& Image_Graph::factory('graph', $Canvas));


Parameters:

mixed   $params   —  The width of the graph, an indexed array describing a new canvas or a valid Image_Canvas object
int   $height   —  The height of the graph in pixels
bool   $createTransparent   —  Specifies whether the graph should be created with a transparent background (fx for PNG's - note: transparent PNG's is not supported by Internet Explorer!)

[ Top ]

displayErrors   [line 273]

void displayErrors( )

Enables displaying of errors on the output.

Use this method to enforce errors to be displayed on the output. Calling this method makes PHP uses this graphs error handler as default Image_Graph::_default_error_handler().


[ Top ]

done   [line 781]

bool done( [mixed $param = false])

Outputs this graph using the canvas.

This causes the graph to make all elements perform their output. Their result is 'written' to the output using the canvas, which also performs the actual output, fx. it being to a file or directly to the browser (in the latter case, the canvas will also make sure the correct HTTP headers are sent, making the browser handle the output correctly, if supported by it).

Parameters are the ones supported by the canvas, common ones are:

'filename' To output to a file instead of browser

'tohtml' Return a HTML string that encompasses the current graph/canvas - this implies an implicit save using the following parameters: 'filename' The "temporary" filename of the graph, 'filepath' A path in the file system where Image_Graph can store the output (this file must be in DOCUMENT_ROOT scope), 'urlpath' The URL that the 'filepath' corresponds to (i.e. filepath + filename must be reachable from a browser using urlpath + filename)

'output' = 'none' Forces the graph to be drawn, but no output is sent to the browser. This allows working with an existing canvas after graphs has been drawn

  • Return: Was the output 'good' (true) or 'bad' (false).

Parameters:

mixed   $param   —  The output parameters to pass to the canvas

[ Top ]

factory   [line 399]

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));

Variables that need to be passed by reference *must* have the & before the variable, i.e:

Image_Graph::factory('line', &$Dataset);

or

Image_graph::factory('bar', array(array(&$Dataset1, &$Dataset2), 'stacked'));

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

'pie' = Image_Graph_Plot_Pie

'radar' = Image_Graph_Plot_Radar

'step' = Image_Graph_Plot_Step

'impulse' = Image_Graph_Plot_Impulse

'dot' or 'scatter' = Image_Graph_Plot_Dot

'smooth_line' = Image_Graph_Plot_Smoothed_Line

'smooth_area' = Image_Graph_Plot_Smoothed_Area 'dataset' = Image_Graph_Dataset_Trivial

'random' = Image_Graph_Dataset_Random

'function' = Image_Graph_Dataset_Function

'vector' = Image_Graph_Dataset_VectorFunction

'category' = Image_Graph_Axis_Category

'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

'polar_grid' = Image_Graph_Grid_Polar

'legend' = Image_Graph_Legend

'font' = Image_Graph_Font

'ttf_font' = Image_Graph_Font

'Image_Graph_Font_TTF' = Image_Graph_Font (to maintain BC with Image_Graph_Font_TTF)

'gradient' = Image_Graph_Fill_Gradient

'icon_marker' = Image_Graph_Marker_Icon

'value_marker' = Image_Graph_Marker_Value

  • 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 new object
mixed   $params   —  The paramaters to pass to the constructor

[ Top ]

height   [line 259]

int height( )

Gets the height of this graph.

The height is returned as 'defined' by the canvas.

  • Return: the height of this graph

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

horizontal   [line 634]

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

Factory method to create horizontal layout.

See Image_Graph::layoutFactory()

  • Return: The newly created layout object

Parameters:

Image_Graph_Element   &$part1   —  The 1st (left) part of the layout
Image_Graph_Element   &$part2   —  The 2nd (right) part of the layout
int   $percentage   —  The percentage of the layout to split at (percentage of total height from the left side)

[ Top ]

layoutFactory   [line 597]

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

Factory method to create layouts.

This method is used for easy creation, since using Image_Graph:: 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.

Use Image_Graph::horizontal() or Image_Graph::vertical() instead for easier access.

  • Return: The newly created layout object

Parameters:

mixed   $layout   —  The type of layout, can be either 'Vertical' or 'Horizontal' (case sensitive)
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

[ Top ]

setCanvas   [line 212]

Image_Canvas &setCanvas( Image_Canvas &$canvas)

Sets the canvas for this graph.

Calling this method makes this graph use the newly specified canvas for handling output. This method should be called whenever multiple 'outputs' are required. Invoke this method after calls to Image_Graph:: has been performed, to switch canvass.

  • Return: The new canvas
  • Since: 0.3.0dev2

Parameters:

Image_Canvas   &$canvas   —  The new canvas

[ Top ]

setLog   [line 297]

void setLog( mixed $log)

Sets the log method for this graph.

Use this method to enable logging. This causes any errors caught by either the error handler {@see Image_Graph::displayErrors()} or explicitly by calling Image_Graph_Common::_error() be logged using the specified logging method.

If a filename is specified as log method, a Log object is created (using the 'file' handler), with a handle of 'Image_Graph Error Log'.

Logging requires Log.

  • Since: 0.3.0dev2

Parameters:

mixed   $log   —  The log method, either a Log object or filename to log to

[ Top ]

vertical   [line 653]

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

Factory method to create vertical layout.

See Image_Graph::layoutFactory()

  • Return: The newly created layout object

Parameters:

Image_Graph_Element   &$part1   —  The 1st (top) part of the layout
Image_Graph_Element   &$part2   —  The 2nd (bottom) part of the layout
int   $percentage   —  The percentage of the layout to split at (percentage of total width from the top edge)

[ Top ]

width   [line 247]

int width( )

Gets the width of this graph.

The width is returned as 'defined' by the canvas.

  • Return: the width of this graph

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


Documentation generated on Mon, 11 Mar 2019 15:39:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.