NAME
Graph::Timeline::DiagonalGD - Render timeline data with GD
VERSION
This document refers to verion 1.5 of Graph::Timeline::DiagonalGD, September 29, 2009
SYNOPSIS
This class is used to clear charts where earliest starting event is at the top of the page and the next event to start follows it (and so on). For each event a box is drawn relative to the length of the event. You get something like this:
first event : XX
second event : XXXXX
third event : XX
fourth event: : XXXXXX
Optionally a client side imagemap can be generated for the events that have a url defined.
An example of usage follows. Note that the labels down the left hand side are based on the id attribute and the colour of the event box on the label.
#!/usr/bin/perl
use strict;
use warnings;
use Graph::Timeline::DiagonalGD;
my $x = Graph::Timeline::DiagonalGD->new();
while ( my $line = <> ) {
chomp($line);
next if $line =~ m/^\s*$/;
next if $line =~ m/^\s*#/;
my ( $id, $label, $start, $end, $url ) = split( ',', $line );
$x->add_interval( label => $label, start => $start, end => $end, id => $id, url => $url );
}
my %render = (
'graph-width' => 400,
'label-width' => 150,
'border' => 10,
'colours' => {
'Ended_Successfully' => [ 128, 128, 128 ],
'Failed' => [ 255, 0, 0 ]
}
);
open( FILE, '>test_diagonal1.png' );
binmode(FILE);
print FILE $x->render(%render);
close(FILE);
open( FILE, '>test_diagonal1.map' );
print FILE $x->map( 'box', 'image1' );
close(FILE);
DESCRIPTION
Render a diagonal event graph based on the input data.
Overview
The render method controls the display. This is inturn controlled by the parameters that are passed in to it.
Constructors and initialisation
Public methods
- render( HASH )
-
The hight of the image created will be 20 pixels per event reported plus 40 pixels for the title, plus an additional 2 * border. The width of the image will be 2 * border + label-width + graph-width.
- border
-
The number of pixels to use as a border around the graph. If omitted will be set to 0.
- label-width
-
The number of pixels used to display the id of the event.
- graph-width
-
The number of pixels within which the events will be drawn.
- colours
-
When an event is rendered the label is used as a key to this hash to return a list of values to use for the colour for that event:
'colours' => { 'Ended_Successfully' => [ 128, 128, 128 ], 'Failed' => [ 255, 0, 0 ] }
The values are for the RGB triplet, if no value is supplied for a label the event will be draw in black.
- map( style, name )
-
Produce a client side imagemap for the data that has a url defined.
- style
-
There are two styles available. 'line' or 'box'. For line the clickable area is the whole line that the event occurs on. For box the clickable area is the box drawn for the event plus 5 pixels to the left and right.
- name
-
This is the name that will be used for the imagemap
Private methods
- _calc_seconds
-
A method to calculate the duration of an event in seconds.
- _title_line
-
The the events are within one day return just a day to use as the title, if they span more than one day return a string 'start TO end' to display as the title.
ENVIRONMENT
None
DIAGNOSTICS
- Timeline->new() takes no arguments
-
When the constructor is initialised it requires no arguments. This message is given if some arguments were supplied.
- Timeline::DiagonalGD->render() expected HASH as parameter
-
Render expects a hash and did not get one
- Timeline::DiagonalGD->render() 'graph-width' and 'label-width' must be defined
-
Both of these parameters must be defined.
- Timeline::DiagonalGD->render() there is not enough data to render
-
None of the input data got passed through the call to window()
- Timeline::DiagonalGD->render() Date range spans into months or years. No can do
-
It is assumed that the data will span, at best, a few days. More than that and we can't realy draw this graph.
- Timeline::DiagonalGD->map() Unknown map style, use 'line' or 'box'
-
Maps come in type styles, 'line' or 'box'. You tried to use something else
- Timeline::DiagonalGD->map() The map requires a name
-
You must supply a name for the map
BUGS
None
FILES
See the diagonal script in the examples directory
SEE ALSO
Graph::Timeline - The core timeline class
AUTHORS
Peter Hickman (peterhi@ntlworld.com)
COPYRIGHT
Copyright (c) 2007, Peter Hickman. All rights reserved.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.