plotly / plotly/plotly.py

On_selection event in faceted plot only works correctly in first facet

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

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

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

説明

Hello,
I’m trying to catch on_selection events in a faceted figure.

I create a simple faceted figure, and attach an on_selection handler to all traces.
As an output, I simply print the customdata, and the selector.xrange.

When selecting an area in the first facet, the selector.xrange is an array of numbers, the customdata corresponds to the data for the left facet.
However, when I do the same in the second facet, the selector.xrange becomes an , and the customdata still appears to be coming from the left facet.

I expect the selector.xrange to also be an array of numbers, when selecting in the right facet.

Here are the sample code (to be executed in jupyter notebook) and a screenshot of the result.

py.init_notebook_mode()

df = pd.DataFrame({
    "x": [1,2,3,4,1,2,3,4],
    "y": [1,2,3,2,1,4,2,3],
    "side": ["left","left","left","left","right","right","right","right"],
    "customdata": [1,2,3,4,5,6,7,8]
})

fig = px.line(df, x="x", y="y", custom_data=["side","customdata"], facet_col="side")

# fig.update_layout(clickmode='event+select')
fig.update_layout(
            dragmode="select",
            clickmode="select"
        )
fig.update_traces(marker_size=20)

f = go.FigureWidget(fig)

def click_handler(trace, points, selector):
    print(trace.customdata)
    print(selector.xrange)
    
f.data[0].on_selection(click_handler)

f

image

Kind Regards

Bart

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

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

はじめの一歩

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

調査の方向性

提供されたfaceted-plotの例をJupyter notebookで実行し、f.data[0].on_selectionを通じてアタッチされたFigureWidgetの選択コールバックを確認します。左と右のファセットを選択したときのselector.xrangeとtrace.customdataを比較します。両方のファセットでの選択結果が、適切な数値範囲とファセットデータを報告すれば完了です。

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

評価

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

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

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