Sankey is not updated on callback
未关闭
还没有人认领这个 Issue。
bug
P3
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
Python 3.8.5; Plotly 4.14.1; Dash 1.19.0
Plotly’s Sankey is not updated with new data on callbacks. A Sunburst plot based on the same data works correctly, as you can see in this example.
value data are changed and passed to JS correctly:
import plotly.graph_objs as go
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Output, Input
import random
app = dash.Dash(__name__)
app.layout = html.Div(
[
html.Button('Change values',
id='btn_change',
n_clicks=0),
dcc.Graph(
id="fig_sunburst",
figure=go.Figure(),
animate=True,
),
dcc.Graph(
id="fig_sankey",
figure=go.Figure(),
animate=True,
),
dcc.Interval(
id=f"update",
interval=2000,
n_intervals=0
),
],
)
@app.callback(
Output('fig_sunburst', 'figure'),
Output('fig_sankey', 'figure'),
Input('btn_change', 'n_clicks')
)
def traces_update(n_clicks):
print(f"update {n_clicks}")
# random data
a1 = random.randint(10, 100)
a2 = random.randint(10, 100)
a3 = random.randint(10 ,100)
a0 = a1+a2+a3
b1 = random.randint(10, 100)
b2 = random.randint(10, 100)
b0 = b1+b2
tot = a0+b0
fig_sunburst = go.Figure(
go.Sunburst(
ids=['tot', 'a0', 'a1', 'a2', 'a3', 'b0', 'b1', 'b2'],
labels=['tot', 'a0', 'a1', 'a2', 'a3', 'b0', 'b1', 'b2'],
parents=['', 'tot', 'a0', 'a0', 'a0', 'tot', 'b0', 'b0'],
values=[tot, a0, a1, a2, a3, b0, b1, b2],
branchvalues="total",
insidetextorientation='horizontal',
)
)
fig_sunburst.update_layout(go.Layout(width=400, height=400,
margin=dict(t=20, l=20, r=20, b=20),))
fig_sankey = go.Figure(
go.Sankey(
node=dict(
label=['tot', 'a0', 'a1', 'a2', 'a3', 'b0', 'b1', 'b2'],
),
link=dict(
source=[0, 0, 1, 1, 1, 5, 5],
target=[1, 5, 2, 3, 4, 6, 7],
value=[a0, b0, a1, a2, a3, b1, b2],
),
)
)
fig_sankey.update_layout(go.Layout(width=400, height=400,
margin=dict(t=20, l=20, r=20, b=20),))
print(fig_sankey["data"][0]["link"]["value"])
return fig_sunburst, fig_sankey
app.run_server()
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用指定的 Python、Plotly 和 Dash 版本运行提供的 Python Dash callback 示例,并比较点击“Change values.”后 Sankey 和 Sunburst 的更新情况。跟踪 Sankey 数据的 callback-to-graph update path;完成的标准是 Sankey 链接值能够像 Sunburst 一样,在 callbacks 中进行可见刷新。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100