Grouped Gantt chart

Hey guys,

I am trying to create a Gantt chart using Plotly, the goal of which is to display the activity of a group of servers over a day. For example, a server might be running or stopped, and I would like to display its status over a 24 hour period.

The Gantt chart appears to accomplish this, using a combination of the ā€˜Using Hours and Minutes in Timesā€™ and ā€˜Group Tasks Togetherā€™ examples provided here:

However I am having issues getting this to work. I think the problem may be with how my data appears when uploaded to Plotly, in the example from the tutorial the data appears as below:

06

Whereas my data appears like this:

My code is basically a carbon copy of the ā€˜Using Hours and Minutesā€™ example, with the addition of grouptasks=True. My data exists in a Pandas Dataframe that is handed to Plotly as such:

graphData = weeklyDetailed_Servers[[ā€˜Nameā€™, ā€˜Start Timeā€™, ā€˜End Timeā€™, ā€˜Statusā€™]]
graphData = graphData.rename(index=str, columns={ā€˜Nameā€™: ā€˜Taskā€™, ā€˜Start Timeā€™: ā€˜Startā€™, ā€˜End Timeā€™: ā€˜Finishā€™,
ā€˜Statusā€™: ā€˜Resourceā€™})

colors = dict(Running=ā€˜rgb(46, 137, 205)ā€™,
Stopped=ā€˜rgb(114, 44, 121)ā€™)

fig = ff.create_gantt(df, colors=colors, index_col=ā€˜Resourceā€™, title=ā€˜Daily Scheduleā€™,
show_colorbar=True, bar_width=0.8, showgrid_x=True, showgrid_y=True, group_tasks=True)
py.plot(fig, filename=ā€˜gantt-hours-minutesā€™, world_readable=True)

Any help or suggestions on fixing this would be greatly appreciated. I am open to using a different graph format as well if there are any better options!

Thanks in advance.

Hi @Kelsicle,

When I take the ā€œUsing Hours and Minutes in Timesā€ example and add group_tasks it seems to work properly.

import plotly.graph_objs as go
import plotly.figure_factory as ff

df = [
    dict(Task='Morning Sleep', Start='2016-01-01', Finish='2016-01-01 6:00:00', Resource='Sleep'),
    dict(Task='Breakfast', Start='2016-01-01 7:00:00', Finish='2016-01-01 7:30:00', Resource='Food'),
    dict(Task='Work', Start='2016-01-01 9:00:00', Finish='2016-01-01 11:25:00', Resource='Brain'),
    dict(Task='Break', Start='2016-01-01 11:30:00', Finish='2016-01-01 12:00:00', Resource='Rest'),
    dict(Task='Lunch', Start='2016-01-01 12:00:00', Finish='2016-01-01 13:00:00', Resource='Food'),
    dict(Task='Work', Start='2016-01-01 13:00:00', Finish='2016-01-01 17:00:00', Resource='Brain'),
    dict(Task='Exercise', Start='2016-01-01 17:30:00', Finish='2016-01-01 18:30:00', Resource='Cardio'), 
    dict(Task='Post Workout Rest', Start='2016-01-01 18:30:00', Finish='2016-01-01 19:00:00', Resource='Rest'),
    dict(Task='Dinner', Start='2016-01-01 19:00:00', Finish='2016-01-01 20:00:00', Resource='Food'),
    dict(Task='Evening Sleep', Start='2016-01-01 21:00:00', Finish='2016-01-01 23:59:00', Resource='Sleep')
]

colors = dict(Cardio = 'rgb(46, 137, 205)',
              Food = 'rgb(114, 44, 121)',
              Sleep = 'rgb(198, 47, 105)',
              Brain = 'rgb(58, 149, 136)',
              Rest = 'rgb(107, 127, 135)')

fig = ff.create_gantt(df, colors=colors, index_col='Resource', title='Daily Schedule',
                      show_colorbar=True, bar_width=0.8, showgrid_x=True, showgrid_y=True, group_tasks=True)
go.FigureWidget(fig)

Could you make a small example that I can copy/paste and see the problem youā€™re hitting (including some simple data)?

Also, when you post Python code, please put it inside a ā€œfenced code blockā€ (https://help.github.com/articles/creating-and-highlighting-code-blocks/). This keep the markdown renderer from messing up the formatting :slightly_smiling_face:
Thanks!
-Jon