GD::Graph::lines graph code


Notes:

@data – is a 'list of lists used to store both the data for the x and y co-ordinates and also the name of each 'column' of figures.

The figures can be read from left to right as they are plotted onto the x axis.

GD::Graph does its best to calculate an appropriate size and scale for the y axis.

new() - the constructor, accepts the size in pixels of the image to be generated.

set() - takes a series of '=>' delimited name value pairs

plot() - accepts the data 'list of lists' structure

export_format – returns the type of graphic image that the host system is capable of producing – for example 'PNG'

binmode – is set for compatibility with non-UNIX systems that treat new line character formatting differently to UNIX

plot – outputs the image, normally to <STDOUT> but here sent to a file handle

If we had been outputting this to a web page, the latter section of code would have used:

print header("image/$format");
binmode STDOUT;
print $my_graph->plot(\@data)->$format();

where 'header' would be a function of CGI.pm, necessitating a :

use CGI qw(:standard);

at the head of the script