Skip to main content

A Pythonic way to make Gantt Charts based off the Google Chart Gantt Chart html/JS charting library

Project description

g_gantt

Table of Contents

Description

g_gantt is a python package that allows you to write Gantt Charts from Google's Javascript charting library in python!

The chart can either be automatically displayed in your browser or saved as html.

Installation

pip install g_gantt

Quick Start

Import g_gantt and datetime for date()

import g_gantt
from datetime import datetime

chart = g_gantt.Chart("Example Chart Title")

chart.add_task(
    task_id="T1",
    task_label="Task 1", 
    resource="Resource 1",
    start=date(2024,10,1),
    end=None, 
    duration=1,
    dependencies=None,
    percent_complete=100,
    )

chart.add_task(
    task_id="T2",
    task_label="Task 2", 
    resource="Resource 2",
    start=date(2024,10,3),
    end=date(2024,10,5), 
    duration=None,
    dependencies="T1",
    percent_complete=30,
    )

chart.add_task(
    task_id="T3",
    task_label="Task 3", 
    resource="Resource 2",
    start=None,
    end=None, 
    duration=3,
    dependencies="T1,T2",
    percent_complete=0,
    )

chart.enable_critical_path(True)

chart.set_dimensions(1500,1000)

chart.show()

chart.save('gantt_chart.html')

Guide

Imports

To get started import g_gantt and import datetime for access to date()

import g_gantt
from datetime import date

First initalize a chart object with your gantt chart title

chart = g_gantt.Chart("Example Chart Title")

Initatilzation

To initalize a chart object the only input you need is your title!

chart = Chart("Example Chart Title")

Add Tasks

Tasks are added to a chart object with the add_task() function. There are many different valid input combinations, below are a few

Basic add_task with all fields defined, and laid out for readability

chart.add_task(
    task_id="T2",
    task_label="Task 2", 
    resource="Resource 1",
    start=date(2024,10,1),
    end=None, 
    duration=1,
    dependencies="T1",
    percent_complete=100,
    )

Task with inputs accepted in default order, and no spacing for readability (Not recommedned)

chart.add_task("T2","Task 2","Resource 1",date(2024,10,1),None,1,"T1",100)

Task with only a duration (Easiest, and best for critical path)

chart.add_task(
    task_id="T1",
    task_label="Task 1", 
    resource="Resource 1",
    start=None,
    end=None, 
    duration=1,
    dependencies=None,
    percent_complete=100,
    )

Task with a Start and an End date

chart.add_task(
    task_id="T1",
    task_label="Task 1", 
    resource="Resource 1",
    start=date(2024,10,1),
    end=date(2024,10,5), 
    duration=None,
    dependencies=None,
    percent_complete=100,
    )

Task with a Start Date and a Duration

chart.add_task(
    task_id="T1",
    task_label="Task 1", 
    resource="Resource 1",
    start=date(2024,10,1),
    end=None, 
    duration=1,
    dependencies=None,
    percent_complete=100,
    )

Task with an End Date and a Duration

chart.add_task(
    task_id="T1",
    task_label="Task 1", 
    resource="Resource 1",
    start=None,
    end=date(2024,10,5), 
    duration=1,
    dependencies=None,
    percent_complete=100,
    )

Task with multiple dependencies

chart.add_task(
    task_id="T1",
    task_label="Task 1", 
    resource="Resource 1",
    start=date(2024,10,1),
    end=date(2024,10,5), 
    duration=None,
    dependencies="T1,T2,T3",
    percent_complete=100,
    )

Task with half a day as duration

chart.add_task(
    task_id="T1",
    task_label="Task 1", 
    resource="Resource 1",
    start=date(2024,10,1),
    end=None, 
    duration=.5,
    dependencies="T1,T2,T3",
    percent_complete=100,
    )

Change Settings

Below are all the settings availble to change a

chart.set_background_color("B4B4B4")
chart.set_dimensions(1500,1000)
chart.set_bar_corner_radius(2)
chart.set_arrows(
    angle = 45,
    color = "#000",
    length = 8,
    radius = 15,
    spaceAfter = 4,
    width = 1.4,
)
chart.enable_critical_path(False) #True by default
chart.enable_percent(False) #True by default
chart.enable_shadow(False) #True by default
chart.enable_sort_tasks(False) #True by default

View and Save Chart

To open the chart in your webbrowser

chart.show()

To save the html

# Save file
chart.save('Filename.html')

License

g_gantt is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ggantt-0.1.11.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ggantt-0.1.11-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file ggantt-0.1.11.tar.gz.

File metadata

  • Download URL: ggantt-0.1.11.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for ggantt-0.1.11.tar.gz
Algorithm Hash digest
SHA256 6260f3c7d51ca9c35afc73d575b6fd156931b56b4272c1e656d695e857ce03d7
MD5 0e71f300aaa258554e07ca972c5d8fbd
BLAKE2b-256 cb53b28c057a05066115b489308a7378f737c38f655933f289161aca26ae3298

See more details on using hashes here.

File details

Details for the file ggantt-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: ggantt-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for ggantt-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 8994e7cbf5c066c167e23ded91ef8ee6aee2b6ceddd3c8b7d458e88ebc0c46d3
MD5 0350e9c7bdc771122ae0f8b80cba8d77
BLAKE2b-256 84b174f37580b0ade0a0ebd56d10849ac7c8d5412841c14569cc11a53422d51f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page