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

Modifying appearance

The Image_Graph Tutorial

Modifying appearance

When you have just created the graph you would most likely want to change the way it looks. For all elements you can basically modify the apperance by changing:

  • Line style

  • Fill style

  • Font

  • Border

  • Background

You CAN change all of the above for all elements, but some element will not "use" them all, ie. a LineChart will not use the "Fill Style".

Modifying line/fill style

There exist the following line styles:

And fill-styles:

First of all you must create the line-/fillstyle:


1 ...
2 $SomeColor =& $Graph->newColor(new Color(R, G, B));
3 // creates a color to use
4
5 $Linestyle =& new Image_Graph_Line_Solid($SomeColor);
6 // create the line style as a solid line with the newly created color
7
8 $Fillstyle =& new Image_Graph_Fill_Solid($SomeColor);
9 // create the fill style as a solid fill with the newly created color
10 ...

When you have created the style you must set it on the graph element:


1 ...
2 $Element->setLineStyle($Linestyle);
3 // set the line style
4
5 $Element->setFillStyle($Fillstyle);
6 // set the fill style
7 ...

It's that easy!.

In the case of the border and background it's basically "just" another linestyle and another fillstyle to set on the element:


1 ...
2 $Element->setBorderStyle($Linestyle);
3 // set the border style
4
5 $Element->setBackground($Fillstyle);
6 // set the background style
7 ...

Using another font

To use another font for displaying text on the element, create a font and assigned it to the element in much the same way as the line-/fillstyle described above. There exist the following types of fonts:


1 ...
2 $StdFont =& new Image_Graph_Font();
3 // create a standard font
4
5 $VertFont =& new Image_Graph_Font_Vertical();
6 // create a vertical standard font
7
8 $TTFFont =& new Image_Graph_Font_TTF("c:\windows\fonts\arial.ttf");
9 // create a true type font
10 ...

When you have created the font, first you have to add it to the graph.


1 ...
2 $Graph->addFont($Font);
3 // add the font to the Graph
4 ...

When you have added it to the graph you make the graph element use the font in a similar way to the fill/linestyle:


1 ...
2 $Element->setFont($Font);
3 // set the font
4 ...

Prev Up Next
Adding plots How to use Image_Graph Plot Layout

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