Giter Club home page Giter Club logo

googlegantt.py's Introduction

googlegantt - A Google Charts Gantt Chart 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()

Produces:

https://chart.googleapis.com/chart?chxt=x,y&chds=0,15&chco=FFFFFF00,CC0000FF,00CC00FF,0000CCFF&chbh=46,4,0&chtt=Test%20Chart&chxl=0:|20/02|21/02|22/02|23/02|24/02|25/02|26/02|27/02|28/02|01/03|02/03|03/03|04/03|05/03|06/03|07/03|1:|Future%20Task|On%20Time%20Task|Late%20Task&chdl=|Late|On%20Time|Upcoming&chd=t:0,5,8|5,0,0|0,3,0|0,0,7&chg=6.66666666667,0&chm=r,4D89F933,0,0,0.466666666667&chs=650x200&cht=bhs

Features

  • 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.

Classes

There are 3 primary classes involved in the creation of a chart.

GanttChart

GanttChart(title,[ **kwargs])

Produce a Gantt Chart.

Keyword Arguments:

  • 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))

Methods:

  • 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

GanttCategory

Optional in common usage. Represents a class of Tasks with a color and a title.

GanttCategory(title[, color])

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'
  • 8-byte

GanttTask

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]])

Keyword Arguments:

  • 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.

More Information

Check out the doctests in the gantt.py file for more information.

License

Copyright (c) 2011 Adam Bard (adambard.com)

Licensed under the MIT License: http://www.opensource.org/licenses/mit-license

googlegantt.py's People

Contributors

adambard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

googlegantt.py's Issues

nstall from github zip failed

ENVIRONMENT
OSX Mavericks

Install from github zip failed

sudo python setup.py install
running install
running bdist_egg
running egg_info
creating googlegantt.egg-info
writing requirements to googlegantt.egg-info/requires.txt
writing googlegantt.egg-info/PKG-INFO
writing top-level names to googlegantt.egg-info/top_level.txt
writing dependency_links to googlegantt.egg-info/dependency_links.txt
writing manifest file 'googlegantt.egg-info/SOURCES.txt'
reading manifest file 'googlegantt.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'googlegantt.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.9-intel/egg
running install_lib
running build_py
creating build
creating build/lib
copying googlegantt.py -> build/lib
creating build/bdist.macosx-10.9-intel
creating build/bdist.macosx-10.9-intel/egg
copying build/lib/googlegantt.py -> build/bdist.macosx-10.9-intel/egg
byte-compiling build/bdist.macosx-10.9-intel/egg/googlegantt.py to googlegantt.pyc
creating build/bdist.macosx-10.9-intel/egg/EGG-INFO
copying googlegantt.egg-info/PKG-INFO -> build/bdist.macosx-10.9-intel/egg/EGG-INFO
copying googlegantt.egg-info/SOURCES.txt -> build/bdist.macosx-10.9-intel/egg/EGG-INFO
copying googlegantt.egg-info/dependency_links.txt -> build/bdist.macosx-10.9-intel/egg/EGG-INFO
copying googlegantt.egg-info/requires.txt -> build/bdist.macosx-10.9-intel/egg/EGG-INFO
copying googlegantt.egg-info/top_level.txt -> build/bdist.macosx-10.9-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/googlegantt-0.6.1-py2.7.egg' and adding 'build/bdist.macosx-10.9-intel/egg' to it
removing 'build/bdist.macosx-10.9-intel/egg' (and everything under it)
Processing googlegantt-0.6.1-py2.7.egg
Removing /Library/Python/2.7/site-packages/googlegantt-0.6.1-py2.7.egg
Copying googlegantt-0.6.1-py2.7.egg to /Library/Python/2.7/site-packages
googlegantt 0.6.1 is already the active version in easy-install.pth

Installed /Library/Python/2.7/site-packages/googlegantt-0.6.1-py2.7.egg
Processing dependencies for googlegantt==0.6.1
Traceback (most recent call last):
  File "setup.py", line 13, in <module>
    "PIL",
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/install.py", line 76, in run
    self.do_egg_install()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/install.py", line 104, in do_egg_install
    cmd.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 211, in run
    self.easy_install(spec, not self.no_deps)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 427, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 478, in install_item
    self.process_distribution(spec, dist, deps)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 519, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 570, in resolve
    requirements.extend(dist.requires(req.extras)[::-1])
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2149, in requires
    dm = self._dep_map
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2141, in _dep_map
    for extra,reqs in split_sections(self._get_metadata(name)):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2560, in split_sections
    for line in yield_lines(s):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1854, in yield_lines
    for ss in strs:
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2163, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1181, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1178, in get_metadata
    return self._get(self._fn(self.egg_info,name))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1238, in _get
    return self.loader.get_data(path)
zipimport.ZipImportError: bad local file header in /Library/Python/2.7/site-packages/googlegantt-0.6.1-py2.7.egg

Bug rendering "Progress" shading under some conditions.

To reproduce:

from googlegantt import GanttChart, GanttCategory
from datetime import date

gc = GanttChart('Test Chart', width=650, height=200,
    progress=date(2011, 02, 27))

on_time = GanttCategory('On Time', '0c0')
late = GanttCategory('Late', 'c00')
upcoming = GanttCategory('Upcoming', '00c')

t1 = gc.add_task('Task1', date(2012, 6, 20), date(2012, 7, 15),
    category=on_time)
t2 = gc.add_task('Task2', depends_on=t1, duration=3, category=upcoming)
t3 = gc.add_task('Task3', date(2012,5,01), duration=50, category=late)

url = gc.get_url()
print url

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.