NAME

GIFgraph - Graph Plotting Module for Perl 5

DESCRIPTION

GIFgraph is a perl5 module to create and display GIF output for a graph. The following classes for graphs with axes are defined:

GIFgraph::lines

Create a line chart.

GIFgraph::bars

Create a bar chart.

GIFgraph::points

Create an chart, displaying the data as points.

GIFgraph::linespoints

Combination of lines and points.

GIFgraph::area

Create a graph, representing the data as areas under a line.

Additional types:

GIFgraph::pie

Create a pie chart.

USAGE

Fill an array of arrays with the x values and the values of the data sets. Make sure that every array is the same size. NB. Necessary to extend with a function setting the values in [x,y1,y2..] sets?

@data = ( 
    ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
    [    1,    2,    5,    6,    3,  1.5,    1,     3,     4]
);

Create a new Graph object by calling the new operator on the graph type you want to create (chart is bars, lines, points, linespoints or pie).

$my_graph = new GIFgraph::chart( );

Set the graph options.

$my_graph->set( 'x_label'           => 'X Label',
                'y_label'           => 'Y label',
                'title'             => 'A Simple Line Graph',
                'y_max_value'       => 8,
                'y_tick_number'     => 8,
                'y_label_skip'      => 2 );

Output the graph

$my_graph->plot_to_gif( "sample01.gif", \@data );

METHODS AND FUNCTIONS

Methods for all graphs

new GIFgraph::chart([width,height])

Create a new object $graph with optional width and heigth. Default width = 400, default height = 300. chart is either bars, lines, points, linespoints, area or pie.

set_text_clr( colour name )

Set the colour of the text.

set_title_font( fontname )

Set the font that will be used for the title of the chart. Possible choices are defined in GD. NB. If you want to use this function, you'll need to use GD. At some point I'll rewrite this, so you can give this a number from 1 to 4, or a string like 'large' or 'small'

plot( \@data> )

Plot the chart, and return the GIF data.

plot_to_gif( "filename", \@data )

Plot the chart, and write the GIF data to filename.

ReadFile ( "filename", some array of columns? )

Read data from filename, which must be a data file formatted for GNUplot. NB. Have to figure out how to call the function.

set( key1 = value1, key2 => value2 ....> )

Set chart options. See OPTIONS section.

Methods for Pie charts

set_label_font( fontname )
set_value_font( fontname )

Set the font that will be used for the vabel of the pie or the values on the pie. Possible choices are defined in GD. NB. If you want to use this function, you'll need to use GD. At some point I'll rewrite this, so you can give this a number from 1 to 4, or a string like 'large' or 'small'

Methods for charts with axes.

set_x_label_font ( font name )
set_y_label_font ( font name )
set_x_axis_font ( font name )
set_y_axis_font ( font name )

Set the font for the x and y axis label, and for the x and y axis value labels. NB. If you want to use this function, you'll need to use GD. At some point I'll rewrite this, so you can give this a number from 1 to 4, or a string like 'large' or 'small'

OPTIONS

Options for all graphs

gifx, gify

The width and height of the gif file in pixels Default: 400 x 300.

t_margin, b_margin, l_margin, r_margin

Top, bottom, left and right margin of the GIF. These margins will be left blank. Default: 0 for all.

Name of the logo file. This should be a GIF file. Default: no logo.

logo_resize, logo_position

Factor to resize the logo by, and the position on the canvas of the logo. Possible values for logo_position are 'LL', 'LR', 'UL', and 'UR'. (lower and upper left and right). Default: 'LR'.

transparent

If 1, the produced GIF will have the background colour marked as transparent. Default: 1.

interlaced

If 1, the produced GIF will be interlaced. Default: 1.

bgclr, fgclr, textclr, labelclr, axislabelclr, accentclr

Background, foreground, text, label, axis label and accent colours.

Options for graphs with axes.

options for bars, lines, points, linespoints and area charts.

long_ticks, tick_length

If long_ticks = 1, ticks will be drawn the same length as the axes. Otherwise ticks will be drawn with length tick_length. Default: long_ticks = 0, tick_length = 4.

y_tick_number

Number of ticks to print for the Y axis. Default: 5.

x_label_skip, y_label_skip

Print every x_label_skipth number under the tick on the x axis, and every y_label_skipth number next to the tick on the y axis. Default: 1 for both.

x_plot_values, y_plot_values

If set to 1, the values of the ticks on the x or y axes will be plotted next to the tick. Also see x_label_skip, y_label_skip. Default: 1 for both.

box_axis

Draw the axes as a box, if 1. Default: 1.

two_axes

Use two separate axes for the first and second data set. The first data set will be set against the left axis, the second against the right axis. If this is set to 1, trying to use anything else than 2 datasets will generate an error. Default: 0.

marker_size

The size of the markers used in points and linespoints graphs, in pixels. Default: 4.

line_width

The width of the line used in lines and linespoints graphs, in pixels. Default: 2.

axis_space

This space will be left blank between the axes and the text. Default: 4.

overwrite

In bar graphs, if this is set to 1, bars will be drawn on top of each other, otherwise next to eeach other. Default: 0.

Options for pie graphs

3d

If 1, the pie chart will be drawn with a 3d look. Default: 1.

pie_height

The thickness of the pie when 3d is 1. Default: 0.1 x GIF y size.

start_angle

The angle at which the first data slice will be displayed, with 0 degrees being "3 o'clock". Default: 0.

AUTHOR

Martien Verbruggen

Contact info

email: mgjv@comdyn.com.au

Copyright (C) 1996 Martien Verbruggen. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.