3D plot redraw() inside a listener cause a recursive loop
未关闭
还没有人认领这个 Issue。
bug
P2
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
I have the following code to be executed:
this.$.plot3d.on('plotly_click', function(d){
self.data[1].x.push(parseFloat(d.points[0].x))
self.data[1].y.push(parseFloat(d.points[0].y))
self.data[1].z.push(parseFloat(d.points[0].z))
redrawing = true
Plotly.redraw(self.$.plot3d);
})
It just adds a 3D point (x,y,z) to a trace and then it redraws the plot.
If I do like this, as far as I seen, the redraw method somewhere trigger again the plotly_click event and this cause a recursive loop.
I used an ugly workaround to fix this, which is the following:
this.$.plot3d.on('plotly_click', function(d){
if(!redrawing){
self.data[1].x.push(parseFloat(d.points[0].x))
self.data[1].y.push(parseFloat(d.points[0].y))
self.data[1].z.push(parseFloat(d.points[0].z))
redrawing = true
Plotly.redraw(self.$.plot3d);
} else {
redrawing = false
}
})
But it's not hte best way. Am I do correctly redrawing the graph in a listener? Is there any other way (maybe the right one) to redraw a graph after a point selection? Is this allowed?
Thank you
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定文件或测试。首先在 3D 图上使用 Plotly.redraw 重现所提供的 plotly_click listener,然后跟踪事件和 redraw 的入口点,以确定 redraw 是否会重新发出点击事件。完成的标准是,文档中描述的行为或修正后的行为不再导致递归循环,并且由适当的回归测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100