plotly / plotly/plotly.py

Sankey is not updated on callback

オープン
#3,059 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
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()

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、指定された Python、Plotly、Dash のバージョンで、提供されている Python Dash callback の例を実行し、「Change values.」をクリックした後の Sankey と Sunburst の更新を比較します。Sankey データの callback-to-graph update path を追跡します。完了の条件は、Sunburst と同様に、callbacks で Sankey のリンク値が目に見えて更新されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。