Produce Gantt charts using the Google Charts API
Author: Adam Bard, http://adambard.com/
This api is designed to allow you to easily and quickly create gantt charts using the Google Charts API. You can save them as images or just produce a URL.
It works swell as long as you want things measured in days.
The method of producing such a chart is heavily influenced by this post by Dave Goerlich. Thanks, Dave.
Quick Start Example
from googlegantt import GanttChart, GanttCategory gc = GanttChart('Test Chart', width=650, height=200, progress=(2011, 02, 27)) on_time = GanttCategory('On Time', '0c0') late = GanttCategory('Late', 'c00') upcoming = GanttCategory('Upcoming', '00c') t1 = gc.add_task('Late Task', (2011, 02, 20), (2011, 02, 25), category=late) t2 = gc.add_task('On Time Task', depends_on=t1, duration=3, category=on_time) t3 = gc.add_task('Future Task', depends_on=t2, duration=7, category=upcoming) url = gc.get_url() image = gc.get_image()
- Optional Progress indicator shades the elapsed area of the chart.
- Flexible chart width and height.
- Specify task colors using css rules.
- Flexibly specify dates using datetime.date objects, or tuples.
- Produce a Google Chart url, or a png image (requires PIL).
- Date span is automatically computed from tasks.
There are 3 primary classes involved in the creation of a chart.
Produce a Gantt Chart.
- width The width of the chart.
- height The height of the chart.
- progress A date representing the current time, to produce a shaded ‘elapsed’ region.
Example initialization:gc = GanttChart('Test Chart', width=600, height=200, progress=(2011, 02, 27))
- GanttChart.get_url() Get a Google Charts URL of the chart, for direct access
- GanttChart.get_image() Get a PIL Image object, to be manipulated
- GanttChart.get_image(save_path) Save a .png image to save_path
Optional in common usage. Represents a class of Tasks with a color and a title.
Produce a category object with a given color. Color is specified using a hex string, and will be converted to an 8-byte rgba hex color string expected by Google Charts from any of the following formats:
- 3-byte, e.g. ‘f00’ => ‘FF0000FF’
- 4-byte, e.g. ‘f00c’ => ‘FF0000CC’
- 6-byte, e.g. ‘ff0000’ => ‘FF0000FF’
Represents a single bar in the chart. Must have a specified start and end date, although these can be computed in different ways.
GanttTask(title[, start_date=None, end_date=None[, **kwargs]])
- start_date The start date of the task
- end_date The end date of the task
- duration The duration, in days, of the task. May be used instead of end_date
- depends_on A GanttTask that must be completed before this one can begin. May be used instead of start_date
- category A GanttCategory to apply to this task.
- color A quick way to specify color. Don’t use this when you have categories declared, you will get blank legend entries.
Either start_date or depends_on must be specified. Same with end_date and duration.
If both start_date and depends_on are specified, depends_on is used.
If both end_date and duration are specified, duration is used.
Check out the doctests in the gantt.py file for more information.
Copyright (c) 2011 Adam Bard (adambard.com)
Licensed under the MIT License: http://www.opensource.org/licenses/mit-license