简体   繁体   English

用Python绘制-甘特图的极限

[英]plotly with Python - limits of Gantt Chart

I have a dataframe like this which is an application log: 我有一个像这样的数据框,它是一个应用程序日志:

+---------+----------------+----------------+---------+----------+-------------------+------------+
|  User   | ReportingSubId | RecordLockTime | EndTime | Duration | DurationConverted | ActionType |
+---------+----------------+----------------+---------+----------+-------------------+------------+
| User 5  |             21 | 06:19.6        | 06:50.5 |       31 | 00:00:31          | Edit       |
| User 4  |             19 | 59:08.6        | 59:27.6 |       19 | 00:00:19          | Add        |
| User 25 |             22 | 29:09.4        | 29:37.0 |       28 | 00:00:28          | Edit       |
| User 10 |             19 | 28:36.9        | 33:37.0 |      300 | 00:05:00          | Add        |
| User 27 |             22 | 13:27.7        | 16:54.9 |      207 | 00:03:27          | Edit       |
| User 5  |             21 | 11:22.8        | 12:37.3 |       75 | 00:01:15          | Edit       |
+---------+----------------+----------------+---------+----------+-------------------+------------+

I wanted to visualize the duration of adds and edits for each user, ad Gantt Chart seemed ideal for me. 我想可视化每个用户的添加和编辑时间,广告Gantt Chart对我来说似乎很理想。

I was able to do it for a sample dataframe of 807 rows with the following code: 我能够使用以下代码对807行的示例数据框进行此操作:

data = []

for row in df_temp.itertuples():
    data.append(dict(Task=str(row.User), Start=str(row.RecordLockTime), Finish=str(row.EndTime), Resource=str(row.ActionType)))

colors = {'Add': 'rgb(110, 244, 65)',
          'Edit': 'rgb(244, 75, 66)'}

fig = ff.create_gantt(data, colors=colors, index_col='Resource', show_colorbar=True, group_tasks=True)

for i in range(len(fig["data"]) - 2):
    text = "User: {}<br>Start: {}<br>Finish: {}<br>Duration: {}<br>Number of Adds: {}<br>Number of Edits: {}".format(df_temp["User"].loc[i], 
                                                                                                                                 df_temp["RecordLockTime"].loc[i], 
                                                                                                                                 df_temp["EndTime"].loc[i], 
                                                                                                                                 df_temp["DurationConverted"].loc[i], 

                                                                                                                                 counts[counts["User"] == df_temp["User"].loc[i]]["Add"].iloc[0],
                                                                                                                                 counts[counts["User"] == df_temp["User"].loc[i]]["Edit"].iloc[0])
    fig["data"][i].update(text=text, hoverinfo="text")

fig['layout'].update(autosize=True, margin=dict(l=150))
py.iplot(fig, filename='gantt-group-tasks-together', world_readable=True)

and I am more than happy with the result : https://plot.ly/~pawelty/90.embed 我对结果感到非常满意: https : //plot.ly/~pawelty/90.embed

However my original df has more users and 2500 rows in total. 但是我最初的df有更多的用户,总共有2500行。 That seems to be too much for plotly. 阴谋似乎太过分了。 I get 502 error. 我收到502错误。

I am a huge fan of plotly but I might have reached it's limit. 我是剧情的忠实粉丝,但我可能已经达到极限了。 Can I change something in order to visualize it with Plotly ? 我可以更改某些内容以便使用Plotly对其进行可视化吗? Any other tool I could use? 我可以使用其他工具吗?

I started using plotly.offline.plot(fig) to plot offline and it worked much faster and I got less errors. 我开始使用plotly.offline.plot(fig)进行离线绘制,它的工作速度更快,而且错误更少。 I also have the problem that my graph doesn't get displayed or sometimes only in fullscreen mode... 我也有一个问题,我的图形无法显示,或者有时只能在全屏模式下显示...

I import plotly instead of plotly.plotly though, otherwise it doesn't work. 我虽然导入plotly而不是plotly.plotly ,否则它不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM