Black Lives Matter. Please consider donating to Black Girls Code today.

Overlapping tasks in discontinuous gantt chart


Thanks for the task grouping functionality @spextrow and @jack.

We are wondering if there is any feature available, that can help when grouped tasks overlap, i.e.

import plotly.plotly as py
import plotly.figure_factory as ff

df = [dict(Task="Job-1", Start='2017-01-01', Finish='2017-02-02', Resource='Complete'),
  dict(Task="Job-1", Start='2017-01-15', Finish='2017-03-15', Resource='Incomplete'),
  dict(Task="Job-2", Start='2017-01-17', Finish='2017-02-17', Resource='Not Started'),
  dict(Task="Job-2", Start='2017-01-17', Finish='2017-02-17', Resource='Complete'),
  dict(Task="Job-3", Start='2017-03-10', Finish='2017-03-20', Resource='Not Started'),
  dict(Task="Job-3", Start='2017-04-01', Finish='2017-04-20', Resource='Not Started'),
  dict(Task="Job-3", Start='2017-05-18', Finish='2017-06-18', Resource='Not Started'),
  dict(Task="Job-4", Start='2017-01-14', Finish='2017-03-14', Resource='Complete')]

colors = {'Not Started': 'rgb(220, 0, 0)',
      'Incomplete': (1, 0.9, 0.16),
      'Complete': 'rgb(0, 255, 100)'}

fig = ff.create_gantt(df, colors=colors, index_col='Resource', show_colorbar=True, group_tasks=True)
py.iplot(fig, filename='gantt-group-tasks-together', world_readable=True)

Note that Job-1 overlaps and cannot determine where the first task of job-1 really ends. Could dotted lines or a unfilled rectangle be used?

Hi @CGully,

I don’t think there’s anything in the figure_factory.create_gantt method to support this. I’m also not clear on why you would want there to be overlap. As far as I understand, there is an inherent assumption that a task will be in at most one state at a time. In this case, for example, it doesn’t really make sense to me for task to be complete and incomplete at the same time. Perhaps there should be validation logic to raise an error or warning when there is overlap within a group?

But feel free to post some other example use cases where you think this would be helpful!

A use case is where you want to see the original schedule along with the revised schedule to see if you’re starting early or ending late.

I was hoping to either set different bar widths based on the ‘Resource’ column the way that works for colors or adjust opacity to 50%.

There is also an assumption that they are utilizing the Gantt chart towards its original purpose. I am utilizing it as a groupby timeline of projects, which suffers the same issue, but there really is not a better solution to this problem with other plotly charts.

A nice interim solution I am looking into would be to edit the opacity of the markers, though I have yet to figure out how.

fig = ff.create_gantt(tmp.to_dict('records'), group_tasks=True, title = "Facility-Project Timeline") 
for shape in fig['layout']['shapes']:
	shape['opacity'] = 0.5

Also, it looks like if you sort your df by start date, this seems to place these items “on top” of other lines most of the time.

There must have been a change because @WolVes solution didn’t seem to work for me. For anyone that happens across this, I was however able to set transparency using a similar method:

fig = ff.create_gantt(data, colors=colors, index_col='Resource', group_tasks=True, showgrid_x = True, showgrid_y=True)
for shape in fig['data']:
    shape['opacity'] = 0.25

Or, individually like: