On_selection event in faceted plot only works correctly in first facet
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 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
Kind Regards
Bart
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 Jupyter notebook 中运行提供的 faceted-plot 示例,并检查通过 f.data[0].on_selection 附加的 FigureWidget 选择回调。选择左侧和右侧 facet 时,比较 selector.xrange 和 trace.customdata。当两个 facet 中的选择都报告相应的数值范围和 facet 数据时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- jupyter-notebook, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100