plotly / plotly/plotly.py

[BUG] `dcc.Graph` `figure` prop may include Plotly.js `_inputArray` for typed arrays

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

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

bug P2 size: 3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

When a dcc.Graph figure data contains typed arrays (for example int8, float32, etc.), the figure can include a Plotly.js internal field _inputArray

In the example below, the _inputArray is included after user interaction but not when the figure is first rendered.

_inputArray duplicates bdata and also includes decoded data, increasing callback payload size and overhead for large datasets.

Possible fixs:

  • strip _inputArray in dcc.Graph before updating the figure prop. But that might be considered a breaking change since some people are now using _inputArray in callbacks.
  • Have an option to not encode np arrays when using dash. This will also fix the issue of customdata not being available is clickData, hoverData if they are np arrays

Other related issues:


When app first renders (no _inputArray):

Image

After hover (with _inputArray):

Image

Sample App:

from dash import Dash, html, dcc, Input, Output
import numpy as np
import plotly.express as px
import json

app = Dash()

data = np.random.normal(0, 1, 250)
fig = px.histogram(data, nbins=20)

app.layout = html.Div([
    dcc.Graph(id="graph", figure=fig),
    html.Pre(id="fig-data")
])


@app.callback(
    Output("fig-data", "children"),
    Input("graph", "figure"),
    Input("graph", "hoverData"),
)
def debug(figure, hoverData):
    return json.dumps(figure["data"][0]["x"], indent=4)


if __name__ == "__main__":
    app.run(debug=True)

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

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

はじめの一歩

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

調査の方向性

まずサンプルの Dash アプリを実行し、ホバー前後の dcc.Graph の figure を調べます。typed-array データと _inputArray フィールドに重点を置いてください。dcc.Graph と Plotly.js 周辺の figure および callback の payload 処理を追跡します。_inputArray に対して選択した動作が一貫して実装され、typed-array における customdata の動作が考慮され、payload サイズが検証されていれば完了です。

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

評価

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

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

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