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

Feature request for Gantt GL (like scatter GL)

The scatter GL is documented here: https://plotly.com/python/line-and-scatter/

I check back every few months to see if Gantt GL has been implemented, but it has been over a year now, so I thought I’d request it here.

Gantt charts are amazing for one of our use cases, but rendering them with more than 25K lines becomes cumbersome. It would be truly incredible to have the speed and performance demonstrated by ScatterGL with Gantt charts… so if some developer out there is listening, this would be awesome if you could implement this!!

Thanks,
rlele5

Hi @rlele5, welcome to the forum! You can actually convert quite easily a figure created with the gant figure factory to scatter gl. For example

import plotly.figure_factory as ff

df = [dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28'),
      dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
      dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')]

fig = ff.create_gantt(df)
import plotly.graph_objects as go
fig2 = fig.to_dict()
for trace in fig2['data']:
    trace['type'] = 'scattergl'
fig2 = go.Figure(fig2)
fig2.show()

That said, I’m not sure whether you will see a performance gain because you will still have the same number of traces. I’m curious to know more about your application, 25k lines sounds like a lot of tasks :-).

Ah, thanks for the sample code. I was under the assumption that ScatterGL is faster because it uses the graphics card to render plots? I saw on the example page that it renders 1 million points in less than a couple seconds. Why couldn’t a GanttGL benefit from this performance improvement as well?

My use case is to track task executions on server threads. Task times can range anywhere from 1 ms to many minutes. For a moderate time range (a couple hours), you could have hundreds of thousands of tasks. We obviously don’t look at all hundreds of thousands, but when all are plotted, it’s easy to visualize small time ranges (< 10 min) with a high density of tasks and zoom in to problem regions. Then once we’re in the zoomed in mode, seeing the timeline makes seeing task dependencies really easy and can quickly point us in the right direction when debugging issues (esp with informative tooltips).

So the ask is to be able to quickly plot up to a couple hundred thousand tasks over a couple hours, and to be able to quickly zoom into the problem region (< 10 min) to be able to scrutinize those tasks. As of now, we filter beforehand to keep the task counts in a single chart to < 25K, but since I saw that incredible performance with ScatterGL (1 million points), I was wondering if it could be applied to the Gantt chart as well!

Thanks again for the response!

@Emmanuelle,

I tried the example you gave me on my data… and it almost works. The underlying code (processing the tasks + creating tooltips, etc) still takes the same time, but when the chart is finally plotted I do see the performance benefits when zooming and looking at tooltips! However, the plot gets messed up.

Here are the before and after:

Normal Gantt (25000 tasks, 6 seconds to zoom):

Applying ScatterGL to Gantt (25000 tasks, zooming instantaneous):

The zooming in the Gantt GL code you provided is almost instantaneous for 25000 tasks vs 6 seconds for the original, but as you can see, the rendering gets messed up. Seems like it’s almost there. Would be amazing if it could become a reality!

I could indeed reproduce the problem on one of the documentation examples. Scatter and scattergl don’t behave in the same way for the following example (which uses how the Gantt rectangle are built, with None values)

import plotly.graph_objects as go
x = [1, 2, 2, 1, 1, 
     4, 6, 6, 4, 4,
     3, 4, 4, 3, 3]
y = [0, 0, 1, 1, None,
    -2, -2, -1, -1, None,
     0, 0, 1, 1, None]
fig = go.Figure(go.Scatter(x=x, y=y, mode='none', fill='toself'))
fig.show()
fig2 = go.Figure(go.Scattergl(x=x, y=y, mode='none', fill='toself'))
fig2.show()


I don’t know whether this is a known difference between scatter and scattergl…

Ah, yep, exactly what I’m seeing. So what’s your opinion on this? Should I create a feature request issue/Jira for this?

I think this is a bug in scattergl.

Check out this issue.

I have a potential fix but need some help from plotly to submit the pull request. Hopefully somebody from plotly can see this.

Hi @ruijin, thanks for figuring this out! Will watch your pull request :smile:. Will see if I can use your patch too - that would be nice