Gantt Chart —

Gantt charts are a great way to show which projects and tasks different teams are working on at a given time. This chart type is heavily used by Project Managers, Task Managers, and anyone else managing multiple workflows. We can use the library in the Periscope Python/R integration to generate the above visual.

The SQL Output requires the following columns

  1. task: the name of the item that the team needs to complete
  2. start: start date of the task
  3. finish: end date of the task

Python 3.6 Code

# SQL output should have 3 columns:
#    1) task: the name of the item that the team needs to complete
#    2) start: start date of the task
#    3) finish: end date of the task

# Importing libraries
import pandas as pd
import plotly.plotly as py
import plotly.figure_factory as ff

# Generating dummy data in case the SQL output isn't in the correct format
community_post = ''
dummy_df = pd.DataFrame()
dummy_df['task'] = ['Task 1', 'Task 2', 'Task 3']
dummy_df['start'] = ['2019-02-07', '2018-12-24', '2018-11-09']
dummy_df['finish'] = ['2019-03-08', '2019-05-08', '2019-04-08']

def style_link(text, link, **settings):
  style = ';'.join([f'{key.replace("_","-")}:{settings[key]}' for key in settings])
  return f'<a href="{link}" style="{style}">{text}</a>'

def plot(df, annotation=None):
  # Create and assign list of column names
  df.columns = [c.title() for c in df.columns]

  # Use figure factory to create gantt chart
  fig = ff.create_gantt(df)
  if annotation is not None:
    fig['layout']['annotations'] = [annotation]

except Exception as e:
    annotation = {
    'x': 0.5,
    'y': 0.5,
    'ax': 0,
    'ay': 0,
    'xref': 'paper',
    'yref': 'paper',
    'text': style_link('DUMMY<br><br><br><br>DATA<br><br><br><br>EXAMPLE', community_post, font_size='60px', font_weight='bold', color='rgba(0, 0, 0, .25)'),
    'showarrow': False,
    'textangle': -25
    plot(dummy_df, annotation=annotation)

More examples of Gantt charts can be found below

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 6 mths agoLast active
  • 232Views
  • 1 Following