graphpite
[ class tree: graphpite ] [ index: graphpite ] [ all elements ]
Prev Next

Adding a plotarea

The Image_Graph Tutorial

Adding a plotarea

Afterwards you must create one or more Image_Graph_Plotarea(s) to use for plotting. After you have created the Image_Graph object you must add all other elements, either directly to the Image_Graph object or an object that has a parent-child chain that terminates in the Image_Graph object, ie Image_Graph->Image_Graph_Plotarea->Image_Graph_Plot_Line->add(Image_Graph_Marker) (this is not actual code!).

To add a new PlotArea to the Graph do either of the following.


1 ..
2 $Plotarea =& $Graph->add(new Image_Graph_Plotarea());
3 ...

or a less compact but perhaps more comprehensible version.


1 ...
2 $Plotarea =& new Image_Graph_Plotarea();
3 $Graph->add($Plotarea);
4 ...

It is very important to remember the "&" (ampersand) after the "=" (equals) sign. Especially if you want to modify/add to the object after the add. Cause PHP 4 assigns by making a copy of the object instead of by reference. So if the "&" is forgotten and you make (some) changes to the created object, they will not be applied to the "added" object because it is another copy. The following pseudo code will demonstrate this:


1 $A = new A(); // create an instance of the A class and assign it to $A
2 $B = $A; // assign $A to $B, this makes a COPY of $A and stores it in $B
3 &$A == &$B;

Line 3 in the above example will evaluate to FALSE, because $B is a COPY of $A and therefore it will NOT refer to the same object (this is pseudo PHP code!).

On the other hand if you did the following:


1 $A =& new A(); // create an instance of the A class and assign THE REFERENCE to it to $A
2 $B = &$A; // assign THE REFERENCE of $A to $B
3 &$A == &$B;

Line 3 in the above example will evaluate to TRUE, because $B is a reference to $A and therefore it will refer to the same object (this is pseudo PHP code!), ie the reference/pointer is the same.

Prev Up Next
Creating the Graph How to use Image_Graph Creating the dataset

Documentation generated on Wed, 15 Sep 2004 10:29:45 +0200 by phpDocumentor 1.2.3