Class Image_Graph

Description

Main class for Graph generation

This class is the starting-point if you want to generate graphs. It handles the various objects involved (e.g. axes, title, list of data-elements). It also provides the basic functions to add data-elements (using addData()), for automatic determination of min/max values for the axes, for data-handling and for the final generation of the graph. An instance of Image_Graph is the root for a tree of class-instances that will store data and settings, will provide methods for customizing the appearance of your graph and will finally create the output (graph on a canvas).

Located in /Graph.php (line 100)


	
			
Variable Summary
Method Summary
 Image_Graph &Image_Graph (int $width, int $height, int $pos_x, int $pox_y)
 object Image_Graph_Data_Common &addData (array $data, [string $representation = "line"], [array $attributes = array()])
 resource getGDImage ([resource $gdResource = null])
 void setAxesColor (mixed $axesColor)
 void setBackgroundColor (mixed $color)
 void setDataDefaultColor (mixed $dataDefaultColor)
 void setDefaultFontOptions ([array $options = array()])
 void setSpaceFromBorder (int $space)
 void stackData ([string/array $stackWhat = "all"])
Variables
object Image_Graph_Axis_X $axisX = null (line 108)

X-axis of diagram

  • access: public
object Image_Graph_Axis_Y $axisY0 = null (line 116)

first Y-axis of diagram

  • access: public
object Image_Graph_Axis_Y $axisY1 = null (line 124)

second Y-axis of diagram

  • access: public
object Image_Graph_Title $diagramTitle = null (line 132)

Title of diagram

  • access: public
Methods
Constructor Image_Graph (line 260)

Constructor for the class

  • access: public
Image_Graph &Image_Graph (int $width, int $height, int $pos_x, int $pox_y)
  • int $width: width of graph-image
  • int $height: height of graph-image
  • int $pos_x: x-position of graph-image
  • int $pox_y: y-position of graph-image
addData (line 401)

Add new data to the graph

This function generate an instance of the given data representation-type (e.g. it will generate an instance of Image_Graph_Data_Line if you supply "line" for $representation). The new object will automatically be added to an internal list of data-objects. A reference to the object which was added to the graph will also be returned by this function. Using that reference you can e.g. call functions like setColor(), or whatever the specific data-element might support, to customize the data-element. You can use the array $attributes to supply attribute-data to the data-element upon creation. This might be quite handy if you add several data and don't want to call e.g. setColor() on each one separately. But this is up to you ... If no "color" is specified in the attributes-array, the "dataDefaultColor" will be used, which can be set using setDataDefaultColor().

object Image_Graph_Data_Common &addData (array $data, [string $representation = "line"], [array $attributes = array()])
  • array $data: data to draw
  • string $representation: data representation (e.g. "line")
  • array $attributes: attributes like color
getGDImage (line 1099)

Create a GD-image-resource for the graph

This function will return a truecolor GD-resource. The GD-resource will have the size you supplied when creating the Image_Graph-instance. If you need a palette GD-resource (e.g. for writing of GIF-images) please be sure to downsample the truecolor GD-resource returned by this function yourself. A truecolor-resource is needed for all alpha-channel-features etc. to receive best possible image-quality. It's possible to optionally give this function an already existing gd-resource. It will then be used for drawing. Please note that (at the moment) no solid standard background-fill will be done.

  • return: truecolor gd-resource containing image of graph
  • access: public
resource getGDImage ([resource $gdResource = null])
  • resource $gdResource: if supplied an existing gd-resource will be used for drawing
setAxesColor (line 315)

Set color of axes

This function allows you to set the color of all axis (axisX, axisY0 and axisY1) all to the same value. It does the same as setting the color for each of those axes manually. It was added solely for convenience since often you will need to give all axes the same new color.

void setAxesColor (mixed $axesColor)
  • mixed $axesColor: any color representation supported by Image_Graph_Color::color2RGB()
setBackgroundColor (line 287)

Sets background color of canvas

void setBackgroundColor (mixed $color)
  • mixed $color: any color representation supported by Image_Graph_Color::color2RGB()
setDataDefaultColor (line 373)

Set default color for new data; used by addData()

You can set a new dataDefaultColor using this function. It will be used for all *following* calls to addData if you don't explicitly supply a color.

void setDataDefaultColor (mixed $dataDefaultColor)
  • mixed $dataDefaultColor: any color representation supported by Image_Graph_Color::color2RGB()
setDefaultFontOptions (line 337)

Set default options for fonts

These options are directly given to the class Image_Text which handles text-output. For a full list of necessary/available font-options please refer to the Image_Text-docs and/or have a look at the examples shipped with the Image_Graph-package. !! Note that the option "font_type" defaults to "ttf" (TrueType-fonts) at the moment. As soon as PHP-internal (bitmap) fonts are also supported by Image_Text this will default to those internal fonts instead. !!

  • access: public
void setDefaultFontOptions ([array $options = array()])
  • array $options: stores information like font_type, font_path, font_file, font_size, antialiasing etc.
setSpaceFromBorder (line 298)

Sets space of graph from each border (of the whole image)

  • access: public
void setSpaceFromBorder (int $space)
  • int $space: space (in pixel) from each border
stackData (line 441)

Set option that data should be stacked

Use this function to turn on data-stacking. If $stackWhat is supplied only specific data-types will be stacked. Please note that possibly not all data-types might support stacking, in which case they will simply be left unstacked. But the base-types "bar" and "line" do support it! If you use both Y-axes then only data on the same axis can be stacked (sure!). So if you have e.g. line-data on both axes they will be stacked independently.

  • access: public
void stackData ([string/array $stackWhat = "all"])
  • string/array $stackWhat: name or array of names of data-types you want to be stacked

Documentation generated on Sat, 21 Feb 2004 23:28:05 +0100 by phpDocumentor 1.3.0RC2