我正在尝试使用甘特图,希望任务与默认任务保持一定的距离,并尝试更新数据,但我看不到帮助我将这些任务分开的更改。我试图更新该图形的数据,但没有帮助。目前,这些任务相互重叠。下面是我的代码-
import plotly.graph_objs as go
from plotly.offline import iplot
fig_pdx_gantt_multiple = plt.figure(figsize=(20,10))
fig_pdx_gantt_multiple = ff.create_gantt(df_pdx_multiple, colors=colors, index_col=‘Resource’, show_colorbar=False,
group_tasks=True,show_hover_fill=True,title=‘TimeSpace Diagram only changes in v4_currState temp id = 745’,
showgrid_x=True, showgrid_y=True,bar_width=10, height = 500)
fig_pdx_gantt_multiple[‘layout’][‘yaxis’].update(ticktext= [‘MarketStreet’ , ‘Broadway’])
fig_pdx_gantt_multiple[‘layout’][‘yaxis’].update(range=[-300,200])
fig_pdx_gantt_multiple.update_xaxes(rangeslider_visible=True)
fig_pdx_gantt_multiple.update_layout(showlegend=True)
fig_pdx_gantt_multiple.data[3].y = (50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0)
fig_pdx_gantt_multiple.data[4].y = (50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0)
fig_pdx_gantt_multiple.data[5].y = (50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,50,50,50,50,50,50,50,50,50,
50,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0)
for tr in fig_pdx.data:
fig_pdx_gantt_multiple.add_trace(tr)
for tr in fig_pdx_street.data:
fig_pdx_gantt_multiple.add_trace(tr)
fig_pdx_gantt_multiple.show()它的输出是-

我想看到的是-(以一种非常老套的方式实现了这一点,在两者之间添加了各种虚拟任务来生成示例)

示例数据如下:
Task Start Finish Resource
0 34108 2020-06-03 23:21:02 2020-06-03 23:21:31 3
1 34108 2020-06-03 23:21:31 2020-06-03 23:21:56 6
2 34108 2020-06-03 23:21:56 2020-06-03 23:21:59 8
3 34108 2020-06-03 23:21:59 2020-06-03 23:22:28 3
4 34108 2020-06-03 23:22:28 2020-06-03 23:22:54 6
5 34108 2020-06-03 23:22:54 2020-06-03 23:22:57 8
6 34108 2020-06-03 23:22:57 2020-06-03 23:23:26 3
7 34108 2020-06-03 23:23:26 2020-06-03 23:23:53 6
8 34108 2020-06-03 23:23:53 2020-06-03 23:23:56 8
9 34108 2020-06-03 23:23:56 2020-06-03 23:24:25 3
10 34108 2020-06-03 23:24:25 2020-06-03 23:24:50 6
210 34109 2020-06-03 23:21:02 2020-06-03 23:21:31 3
211 34109 2020-06-03 23:21:31 2020-06-03 23:21:56 6
212 34109 2020-06-03 23:21:56 2020-06-03 23:21:59 8
213 34109 2020-06-03 23:21:59 2020-06-03 23:22:28 3
214 34109 2020-06-03 23:22:28 2020-06-03 23:22:54 6
215 34109 2020-06-03 23:22:54 2020-06-03 23:22:57 8
216 34109 2020-06-03 23:22:57 2020-06-03 23:23:26 3
217 34109 2020-06-03 23:23:26 2020-06-03 23:23:53 6
218 34109 2020-06-03 23:23:53 2020-06-03 23:23:56 8
219 34109 2020-06-03 23:23:56 2020-06-03 23:24:25 3
220 34109 2020-06-03 23:24:25 2020-06-03 23:24:50 6谢谢
发布于 2020-06-30 17:42:38
我也没有任何使用甘特图的经验,所以我在做大量研究的同时编写了代码。第一个显示id,但没有将它们组合在一起;第二个显示id为一个组
import plotly.figure_factory as ff
color = ['#000ff','#1e90ff','#6495ed','#00bff','#87cefa','#add8e6','#b0e0e6','#afeeee','#e0ffff','#00ffff']
fig = ff.create_gantt(df, colors=color, index_col='Resource',
show_colorbar=True, bar_width=0.2, showgrid_x=True, showgrid_y=True)
fig.show()id group_tasks=True
import plotly.figure_factory as ff
color = ['#000ff','#1e90ff','#6495ed','#00bff','#87cefa','#add8e6','#b0e0e6','#afeeee','#e0ffff','#00ffff','#40e0d0']
fig = ff.create_gantt(df2, colors=color, index_col='Resource',
show_colorbar=True, bar_width=0.2, showgrid_x=True, showgrid_y=True, group_tasks=True)
fig.show()


https://stackoverflow.com/questions/62652155
复制相似问题