Version 24 (modified by rjollos, 3 years ago) (diff)

Updates in response to #9508.

Trac jsGantt plugin


A plugin which allows Trac ticket data to be displayed in a jsGantt chart in a wiki page. Tasks and milestones are links to the corresponding ticket or milestone.

Configurable field names allow integration with other plugins such as MasterTicketsPlugin (for dependencies), SubticketsPlugin (for parent/child relationships) and TimingAndEstimationPlugin (for estimated and total hours).


[[TracJSGanttChart(sample=1)]] displays the sample project from [[TracJSGanttChart(milestone=Test)]] displays all the tickets in the Test milestone.

jsGantt sample tasks in a wiki page


The chart display can be controlled with a number of macro arguments:

Argument Version Description Default
formatsWhat to display in the format control. A pipe-separated list of minute, hour, day, week, month, and quarter (though minute may not be very useful). day|week|month|quarter
format Initial display format, one of those listed in formats First format
sample Display sample tasks (1) or not (0) 0
res Show resource column (1) or not (0) 1
dur Show duration colunn (1) or not (0) 1
comp Show percent complete column (1) or not (0) 1
caption Caption to place to right of tasks: None, Caption, Resource, Duration, %Complete Resource
startDate Show start date column (1) or not (0) 1
endDate Show end date column (1) or not (0) 1
dateDisplay Date display format: 'mm/dd/yyyy', 'dd/mm/yyyy', or 'yyyy-mm-dd' 'mm/dd/yyyy'
openLevel Number of levels of tasks to show. 1 = only top level task. 999
expandClosedTickets0.9Show children of closed tickets (1) or collapse the subtree (0). 1
colorBy Field to use to choose task colors. Each unique value of the field will have a different color task. Other likely useful values are owner and milestone but any field can be used. priority
root When using something like Subtickets plugin to maintain a tree of tickets and subtickets, you may create a Gantt showing a ticket and all of its descendants with root=<ticket#>. The macro uses the configured parent field to find all descendant tasks and build an id= argument for Trac's native query handler.

Multiple roots may be provided like root=1|12|32.

When used in a ticket description or comment, root=self will display the current ticket's descendants.
goal 0.9 When using something like MasterTickets plugin to maintain ticket dependencies, you may create a Gantt showing a ticket and all of its predecessors with goal=<ticket#>. The macro uses the configured succ field to find all predecessor tasks and build an id= argument for Trac's native query handler.

Multiple goals may be provided like goal=1|12|32.

When used in a ticket description or comment, goal=self will display the current ticket's predecessors.
lwidth The width, in pixels, of the table of task names, etc. on the left of the Gantt.
showdepShow dependencies (1) or not (0)1
userMap0.8Map user IDs to full names (1) or not (0).1
omitMilestones0.8Show milestones for displayed tickets (0) or only those specified by milestone= (1)0

Site-wide defaults for macro arguments may be set in trac.ini. option.<opt> overrides the built-in default for <opt> from the table above.

All other macro arguments are treated as TracQuery specification (e.g., milestone=MS1|MS2) to control which tickets are displayed.


  1. Install globally with:
      sudo easy_install
  2. Enable the plugin by updating TracIni file (..../trac.ini) as follows:
      tracjsgantt.* = enabled
  3. Configure custom fields for the start date and finish date. Additional custom fields will be necessary (or may be provided by the associated plugins) if you wish to use additional features such as parent/child and predecessor/successor ticket relationships, and work estimates. See TracTicketsCustomFields for more details.
  4. Configure the plugin at its own configuration section, placed into 'trac.ini' file as follows:
      # To work with Timing and Estimation for percent complete
      fields.estimate = estimatedhours
      fields.worked = totalhours
      # Each unit in estimate is 1/8 of a day
      days_per_estimate = 0.125
      # To work with Master Tickets for dependencies
      fields.pred = blockedby
      fields.succ = blocking
      # To work with Subtickets for parent/child relationships
      fields.parent = parents
      # To work with ChildTickets plugin
      # parent_format = #%s
      # Custom fields for start and due dates
      fields.start = userstart
      fields.finish = userfinish
      date_format = %Y-%m-%d
      milestone_type = milestone
  5. Restart web server on command line:
        $ sudo /etc/init.d/apache2 restart

Configuration details

TracJsGanttPlugin is intended to be flexible enough to get data from various plugins by configuring the field names for those plugins in trac.ini. It is known to work with TimingAndEstimationPlugin (for estimated and total hours), MasterTicketsPlugin (for FS dependencies), and SubticketsPlugin for parent/child relationships. Custom fields for start and finish date are also supported.

Tasks are colored based on ticket attributes. When colored by priority colors are consistent with the colors used in Trac reports. Other coloring choices (e.g., by milestone or owner) use arbitrary, unique colors.

All of the fields.* items name custom fields which may contain data for the Gantt.

When estimate and worked are both configured, the plugin attempts to display (100 * worked/estimate) as the percent complete. The example works with TimingAndEstimationPlugin. Alternatively, if percent is configured, the plugin attempts to display it as the percent complete (it should be a number from 0 to 100). If none of those are configured, all tasks will be marked as 0% complete.

When pred and succ are configured the plugin uses them to determine the task dependencies. The example works with MasterTicketsPlugin. If these fields are not configured, no dependencies are shown.

When parent is configured, it is the field which holds the parent ticket number. The example works with Subtickets. If this field is not configured, no parent/child relationship will be displayed. If it is configured, the Gantt can be collapsed by the user to show or hide subtasks. (parent_format determines the format of the content of the parent field. Use "%s" (default) for SubticketsPlugin, "#%s" for ChildTicketsPlugin.)

When start and finish are configured, the plugin uses them to set task start and finish dates. The date_format field is a Python strptime() format specifier which describes the contents of start and finish. If these fields are not configured, all tasks end today and have a 1-day duration.

When estimate and finish are both configured (and start is not configured or not on the ticket), the plugin attempts to determine the start of the task from finish and estimate as start = finish - estimate with consideration for weekends and hours per day.

The milestone_type may be used to have a custom ticket type show up as milestones on the chart. If this field is not specified, only Trac milestones are displayed as milestones.

Bugs/Feature Requests

Existing bugs and feature requests for TracJsGanttPlugin are here.

If you have any issues, create a new ticket.

Known issues

  1. Only one chart can be displayed per page.

Planned enhancements

  1. Allow configuration of default task duration.
  2. Display a legend of task colors and their meaning (e.g., which milestone or owner they represent).
  3. Allow some tasks to be open or closed by default.
  4. Figure out finish date if start and estimate are provided.
  5. Display critical path
  6. Display slack time

Source & Download

You can check out TracJsGanttPlugin from here using Subversion, or browse the source with Trac.

Download the zipped source from here.

Recent Changes

[14075] by ChrisNelson on 2014-08-07 14:39:09
Save schedule under Trac 1.0, bump version. Refs #11773.

NOTE: This is incompatible with versions of Trac prior to 1.0!

Plugin version now 0.11. That's a little confusing since plugin 0.10
worked in Trac 0.11(.6). Sorry. This is temporary. Hopefully I'll get
some other changes in soon and bump the plugin version again.

There are other database accesses that should be converted to 1.0 style
but I haven't fully tested those changes yet.

[14016] by rjollos on 2014-07-23 21:28:33
Added license text and file headers. Tidied up indentation. Refs #11871.
[13868] by ChrisNelson on 2014-04-24 16:38:38
Use executemany() when inserting multiple rows. Refs #11027.

Required for cross-db compatibility.

Light testing shows this still works for me in PostgreSQL so it
doesn't seem I broke anything. I need SQLite feedback, though.

[13853] by ChrisNelson on 2014-04-16 22:43:53
Remove comment that has been addressed. Refs #11489.
[13852] by ChrisNelson on 2014-04-16 22:41:44
Handle collapsing groups on multi-Gantt pages. Refs #11489.

Needed to add the chart ID to more DOM element IDs for uniqueness.

[13842] by ChrisNelson on 2014-04-09 13:55:57
Don't schedule closed tickets in background rescheduler. Refs #9648.

Also add some logging.

[13841] by ChrisNelson on 2014-04-09 13:55:54
Simplify interface to prune and repair routines. Refs #9648.
[13840] by ChrisNelson on 2014-04-09 13:55:51
Factor our graph repair. Refs #9648.
[13839] by ChrisNelson on 2014-04-09 13:55:48
Rewrite algorithm to identify tickets to reschedule. Refs #9648.

This is a shorter, cleaner algorithm:

  • Find what's active now
  • Find what was active
  • wasActive - isActive should be idled
  • isActive should be rescheduled
    • Save only if schedule changes

It also works. ;-) With the old algorithm if you has two goals scheduled
and interrupted the earlier one, the tasks for the second goal weren't
moved up. The code to find active and idled tickets was weak and
fragile and not worth fixing since it was also slow. In general, this
new approach handles a lot less data, defers getting ticket details as
long as possible, and gets them for many fewer tickets. In my
playground, I used to query 150 tickets (basically, everything in the
database) and now I query 4-5 tickets (the active set). I expect that
ratio to scale to production. Since querying for ticket details was the
longest part of rescheduling, this is much, much faster than the old

[13838] by ChrisNelson on 2014-04-09 13:55:45
Factor out schedule and schedule_change update. Refs #9648.

This makes the code which finds affected tickets clearer, closer.


Author: ChrisNelson
Maintainer: ChrisNelson
Contributors: rjollos, bof, Matt Sable

Attachments (1)

Download all attachments as: .zip