SVG::Timeline - Create SVG timeline charts
use SVG::Timeline; my $tl = SVG::Timeline->new; $tl->add_event({ start => 1914, end => 1918, text => 'World War I', }); $tl->add_event({ start => 1939, end => 1945, text => 'World War II', }); print $tl->draw;
This module allows you to easily create SVG documents that represent timelines.
An SVG timeline is a diagram with a list of years across the top and a number of bars below. Each bar represents a period of time.
Creates and returns a new SVG::Timeline object.
Takes an optional hash reference containing configuration options. You probably don't need any of these, but the following options are supported:
events - a reference to an array containing events. Events are hash references. See add_event below for the format of events.
width - the width of the output in any format used by SVG. The default is 100%.
height - the height of the output in any format used by SVG. The default is 100%.
aspect_ratio - the default is 16/9.
viewport - a viewport definition (which is a space separated list of four integers. Unless you know what you're doing, it's probably best to leave the class to work this out for you.
svg - an instance of the SVG class that is used to generate the final SVG output. Unless you're using a subclass of this class for some reason, there is no reason to set this manually.
default_colour - the colour that is used to fill the timeline blocks. This should be defined in the RGB format used by SVG. For example, red would be 'RGB(255,0,0)'.
years_per_grid - the number of years between vertical grid lines in the output. The default of 10 should be fine unless your timeline covers a really long timespan.
bar_height - the height of an individual timeline bar.
bar_spacing - the height if the vertical space between bars (expresssed as a decimal fraction of the bar height).
decade_line_colour - the colour of the grid lines.
bar_outline_colour - the colour that is used for the outline of the timeline bars.
The height of the timeline in "calculated units".
The widtn in "calulated units".
The number of horizontal units that each year should take up.
Method to draw the underlying grid.
Method to draw the timeline.
Returns the minimum year from all the events in the timeline.
Returns the maximum year from all the events in the timeline.
The number of years that all the events in the timeline span.
Dave Cross <dave@perlhacks.com>
Copyright (c) 2017, Magnum Solutions Ltd. All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SVG::Timeline, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SVG::Timeline
CPAN shell
perl -MCPAN -e shell install SVG::Timeline
For more information on module installation, please visit the detailed CPAN module installation guide.