Project::Gantt - Create Gantt charts to manage project scheduling
#!/usr/bin/perl -w # a fun, imaginary wednesday use strict; use Project::Gantt; use Project::Gantt::Skin; my $skin= new Project::Gantt::Skin( doTitle => 0); my $day = new Project::Gantt( file => 'hourly.png', skin => $skin, mode => 'hours', description => 'A day in the life'); my $al = $day->addResource( name => 'Alex'); $day->addTask( description => 'Finish sleep', resource => $al, start => '2004-07-21 00:00:00', end => '2004-07-21 08:30:00'); $day->addTask( description => 'Breakfast/Wakeup', resource => $al, start => '2004-07-21 08:30:00', end => '2004-07-21 10:00:00'); my $sub = $day->addSubProject( description => 'Important Stuff'); $sub->addTask( description => 'Contemplate my navel', resource => $al, start => '2004-07-21 10:00:00', end => '2004-07-21 11:00:00'); $day->addTask( description => 'Lunch', resource => $al, start => '2004-07-21 11:00:00', end => '2004-07-21 12:30:00'); $sub->addTask( description => 'Wonder about life', resource => $al, start => '2004-07-21 11:00:00', end => '2004-07-21 11:22:00'); $day->addTask( description => 'Code for a while', resource => $al, start => '2004-07-21 12:30:00', end => '2004-07-21 17:00:00'); $day->addTask( description => 'Sail', resource => $al, start => '2004-07-21 17:00:00', end => '2004-07-21 20:30:00'); $day->display();
Project::Gantt provides the ability to easily draw Gantt charts for managing the schedules of projects and many other things. Gantt charts provide a simple, easy to comprehend visual representation of a schedule.
The code above creates a simple chart to display the hour-by-hour breakdown of a sample day. Notice the Project::Gantt::Skin object in use. This allows the look and feel of a Gantt chart to be customized. Also note that tasks are divided into two main categories: those that fall directly under the project, and those which are members of the subproject "Important Stuff". Note also that the chart itself will be written to a file in the current working directory called "hourly.png". This filename attribute may be set to something such as "png:-" to send output directly to STDOUT.
As can be seen from the example, the methods that will be called by a user of this module include: addResource,addTask, addSubProject, and display. The names of these methods suggest their purpose, but they will be further explained.
new takes the following parameters: the skin object in use (if not using the default), the filename to use when writing the chart (use "png:-" to write to STDOUT), an overall description for the chart, and the time mode for output. The filename and description are fairly self explanatory. The Project::Gantt::Skin object will be covered later in this document. The time mode selects which unit of time to use when displaying the chart. This unit can be one of the following: hours, days, and months. Note that when using the months mode, small overflows of pixels may be present (i.e., one pixel more than should be). Normally these are not noticeable. They are a result of the calculation used to determine how many pixels a timespan should fill when using month more. This is because of the discrepancies between days in various months. If swim lanes are not in use (see the section on Project::Gantt::Skin), these errors are unnoticeable.
addResource really only requires a name parameter at this point. The method will accept whatever you give it, but currently only the name parameter has any impact on the resulting chart.
addTask attaches a Project::Gantt::Task object to the Project::Gantt instance that called it. The calling instance may be the root project, or any subproject. The task will be anchored directly underneath it. Parameters that must be passed to this method are as follows: a description of the task, the resource assigned to its undertaking, the starting date of the task and its end date.
addSubProject returns an instance of Project::Gantt anchored underneath the instance that called it. Thanks to Peter Weatherdon, you can now create nested sub-projects using this method on an existing sub-project object. This reference may then be used to call addTask and create a container relationship with Project::Gantt::Task objects. Currently, the only necesarry parameter is a description of the sub-project.
Oddly enough, display writes the chart to a file.
Project::Gantt::Skin objects allow users to customize the color scheme of a chart. The skin object is passed to Project::Gantt during construction. All aspects of the skin are set during its construction as well. The following facets of the chart may be modified:
primaryText controls the font fill color for all but the sub-project description. The default is black.
secondaryText controls the font fill for sub-projects. It defaults to a grey color (#969696).
primaryFill is the color that fills the information boxes for rows representing tasks. The default is a blue color (#c4dbed).
secondaryFill is the color used by sub-project rows for informational boxes, as well as the fill for the calendar header. The default is a grey color (#e5e5e5).
infoStroke is the stroke color for the informational boxes. This defaults to black.
containerStroke is the stroke color for sub-projects on the chart. This defaults to black.
containerFill is the fill color for sub-project items. This defaults to grey (as defined by Image::Magick).
itemFill is the fill color for task items on the chart. This defaults to blue. Note that there is no stroke color for tasks (it is set to the fill).
background is quite obviously the background color. This defaults to white.
font is the name of the font file as it is passed to Image::Magick. See the docs for that module for more information. The default value for this property is determined by searching @INC for the directory of your Project::Gantt installation, and is set to the copy of Bitstream Vera included in the distribution.
doTitle is a boolean that determines whether the title of the chart is drawn on it.
doSwimLanes is a boolean that determines whether lines should be drawn seperating each time interval from the header to the end of the graph. This makes it easy to see the exact values.
Alexander Christian Westholm, <awestholm AT verizon.net>
August, 2004: Original Version
January 2005: Modifications made by Peter Weatherdon (peter.weatherdon AT us.cd-adapco.com), including various bug fixes, and nested sub-projects.
Copyright 2005, Alexander Christian Westholm.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 115:
You forgot a '=back' before '=head2'