SVG::Timeline::Compact - A Moose based SVG Timeline drawing class.
version 0.003
use SVG::Timeline::Compact; use DateTime::Format::Natural; my $svg=SVG::Timeline::Compact->new(); my $parser = DateTime::Format::Natural->new; my $start=$parser->parse_datetime("12pm"); my $end=$parser->parse_datetime("1pm"); $svg->add_event( start=>$start, end=>$end, name=>"Event 1", tooltip=>"First Event of the example", color=>"#ff00ff" ); $start=$parser->parse_datetime("12:45pm"); $end=$parser->parse_datetime("1:20pm"); $svg->add_event( start=>$start, end=>$end, name=>"Event 2", tooltip=>"Second Event of the example", color=>"#ff000f" ); $start=$parser->parse_datetime("3:00pm"); $end=$parser->parse_datetime("5:20pm"); $svg->add_event( start=>$start, end=>$end, name=>"Event 3", tooltip=>"Third Event of the example", color=>"#fff00f" ); open my $fh,">","test.svg" or die "unable to open test.svg for writing"; print $fh $svg->to_svg;
This module originated because SVG::Timeline did not meet my requirements.
The major difference with SVG::Timeline are as follows
Start and End are actual DateTime Objects.
Auto-calculation of timescale ( min, hours, days, months, years ) based on the events and grid size.
Auto Layout to fit multiple events on same row.
Tooltips.
Takes the following parameters:
Default 1, If the event duration is less then min_width then the resultant bar in the graph is made equal to min_width e.g. if start==end then instead of drawing an event with width 0, an event 1 px width is drawn.
Default 20, The height of the bar, This assumes that our text is 12 px high.
Default 800, The width of the drawing area in px.
Takes a hash corresponding to L<SVG::Timeline::Compact::Event> and adds it to the event list.
The hash fields are:
Optional, Event ID.
Required, DateTime Object representing the Start Time.
Required, DateTime Object representing the End Time.
Required, Event Name.
Optional, Event Tooltip.
Optional, The RGB value for filling the rectangle representing the event.
Vijayvithal <jvs@cpan.org>
This software is copyright (c) 2017 by Vijayvithal.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install SVG::Timeline::Compact, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SVG::Timeline::Compact
CPAN shell
perl -MCPAN -e shell install SVG::Timeline::Compact
For more information on module installation, please visit the detailed CPAN module installation guide.