Trace: » direction » getting_started_guide » horizontal_plots

Horizontal Plots in Image_Graph

With the release of Image_Graph version 0.6.0, the long awaited (re)-introduction of horizontal plots arrived. Back in ‘ye ole’ days Image_Graph used to support horizontal plots, but this (rather clumsy1)) implementation was broken with a needed change in the way the axis are handled.

The way Image_graph now handles horizontal plots, the direction (horizontal or vertical) is not a property of the plot - there is actually nothing that is special about a horizontal plot versus a vertical plot, other than the direction. Since there is no huge difference, why should the plots be different? A horizontal plot should have exactly2) the same look as the vertical, except that it is tilted 90 degrees.

Therefore in Image_Graph horizontal plots are a property of the plotarea, since it is the plotarea’s job anyway to handle coordinates and axis.

Actual Usage

“Enough talk, how does it work?”

Well this is actually very easy. The direction of the plotarea (or plots) is simply specified by a (the) 3rd parameter on the constructor of the plotarea (the first 2 are the type of the x-axis and the type of the y-axis).

So you normally create a vertical plotarea like this:

$Plotarea =& Image_Graph::factory('plotarea');

Assuming default axis (x is category, y is linear). If you specify axis the constructor becomes:

$Plotarea =& Image_Graph::factory('plotarea', array('category', 'axis'));

Again assuming default axis.

Since the direction is the 3rd parameter we have to explicitly specify the 2 axis “types” before specifying the direction. The valid values for direction are: ‘vertical’3) and ‘horizontal’. Meaning that to have a horizontal plot you need:

$Plotarea =& Image_Graph::factory('plotarea', array('category', 'axis', 'horizontal'));

The rest of the graph is the usual stuff (unless you explicitly want something to look different).


Image_Graph Example

1) It simply involved swapping x and y coordinates of the plot, while this being what a horizontal plot actually is, this approach was (is) a bit simplified
2) to some degree of detail
3) default
 
image_graph/components/horizontal_plots.txt · Last modified: 2006/02/22 18:19