PrePAN

Sign in to PrePAN

SVG::Timeline::Compact Compact SVG Timeline Drawing Module

Good

Synopsis

use SVG::Timeline::Compact;
use DateTime::Format::Natural;

use strict;
use warnings;
use diagnostics;
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;

Description

This module originated because SVG::Timeline did not meet my requirements.

I communicated with the author and went through the code with an intention of contributing to it, but realized that it follows a different design philosophy and use case.

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.

Comments

Please sign up to post a review.