小编Iot*_*ron的帖子

在plotlyexpress中添加甘特图的超链接?

我使用甘特图来显示几年来分布式网络中大量传感器的记录数据。(网络中的一些节点间歇性地打开或关闭,因此这是一目了然地显示整个数据集的有效方法。)我使用plotlyexpress从文件名列表生成甘特图,因此每个甘特条对应到给定日期的图表的 .PNG 文件,我可以轻松地将结果导出为交互式 .html 文档。

我想为甘特图上的每个条形添加一个可点击的链接,以便单击给定的条形将打开相关日期的绘图。这将使探索数据变得更加容易。我可以生成链接,但无法从甘特图中打开它们。

这是我第一次通过 MWE:

# WIP: Can I set up the Gantt chart so that clicking on an entry takes you to that graph?
import plotly.express as px
import pandas as pd

string1 = "<a href=https://www.nytimes.com/> link </a>"

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

fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", text="Filename") # textposition argument not possible
fig.update_traces(textposition='outside') …
Run Code Online (Sandbox Code Playgroud)

python gantt-chart plotly

2
推荐指数
1
解决办法
740
查看次数

标签 统计

gantt-chart ×1

plotly ×1

python ×1