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

How to use Plotly to make Gantt chart with discontinuous tasks

I am using Plotly’s Python API to build a Gantt chart for tasks that are discontinuous. The current method available in Ploty’s library can build gantt charts where a task has one start and end date, whereas I am trying to plot a gantt chart for tasks with multiple start and end dates ( task is partially completed at different times). For example, a task may start on Jan 1 2016 and halt on Feb 30 2016, then start again on 1 May 2016 and finish completion on 1 June 2016. The current method only allows input of one start and end date, where a horizontal bar is displayed from the start to the end. I want two (or multiple) horizontal bars to show clearly which periods the task was ‘active’ and ‘inactive’. The link below shows an image of the sort of gantt chart I want to make.

I would appreciate it if someone could let me know how to go about making such a chart.

Thanks,

Abdul Qadir

Hi Abdul,

In regards to your question, there is nothing currently in place that allows for .create_gantt to do what you are requesting. What you would have to do is simply make multiple of the same task in your dictionary/dataframe and assign a different task to each one.

However, this is a very good suggestion and I will work on getting it implemented as soon as I can. Will probably take a week or so as I have several other tasks at the moment. :slight_smile:

Thanks again

3 Likes

I would like to use that functionality too. Do you maybe have an ETA for implementation? Then I can stop searching for a package that has this functionality :slight_smile:.

Hi there,

My apologizes for such a late reply. The lateness should implicity reveal our plans at getting it implemented. =) But if I were to give you a time, I would say by the end of October.

Hey there,

I had the same problem and added sth. that might solve your problem.
Take a look at the pull request here: https://github.com/plotly/plotly.py/pull/588

  • Andreas

Thank you @spextrow ! Your pull request has been merged.

A gantt chart with tasks that have gaps / discontinuities (from @spextrow 's test):

Thanks for this @spextrow and @jack . Much appreciated!

I have been trying to use create_gantt method to create a gantt chart with discontinuities, using the same code as in @spextrow’s test. However, when specifying group_task=True, I receive an error (TypeError: create_gantt() got an unexpected keyword argument ‘group_task’). I have updated plotly and I continue to get this error. Has anyone else successfully used this method?

Hey aqadir,

sorry for the delayed response.
If you are using the pip version of plot.ly, you cannot use the group_task function. The pip package was last updated on August 23th 2016, as you can see here: https://pypi.python.org/pypi/plotly.

So if you want to use this, you have to either manually install the github version, or wait until the devs upgrade the pip package.
What I have done to get this to work in my current project is to copy or symlink the tools.py file into the currently installed package folder (/site-packages/plotly).

Hope I could help.

Thanks @spextrow! Copying the code to the tools.py file worked.

Hi, related to this issue, I’m doing a Gantt chart with discontinuous tasks. I’m using the GitHub master, and create_gantt(data,group_tasks=True) appears to work, but I cannot get an offline chart created. I edited offline.py as described in #399, but I still get

Traceback (most recent call last):
File “<pyshell#3>”, line 1, in/
plotly.offline.plot(fig, filename=‘index_Gantt.html’)
File “/usr/lib64/python2.7/site-packages/plotly-1.12.10-py2.7.egg/plotly/offline/offline.py”, line 411, in plot
’100%’, ‘100%’, global_requirejs=False)
TypeError: _plot_html() got multiple values for keyword argument ‘global_requirejs’

Any help or pointers would be appreciated. I’m new to Python, so apologies if this is a silly question.

Hey there, are you still experiencing that problem.

We had an offline bug for a while but as of now it should be resolved.

Could you post me your code below so that I could have a look at how you are making your gantt chart online?

Hi,
Thanks for this very useful feature !
Just be careful: the syntax for this keyword is “group_tasks=True”, not “group_task=True”. See https://plot.ly/python/gantt/