3D plot redraw() inside a listener cause a recursive loop
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 28
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by reproducing the supplied plotly_click listener with Plotly.redraw on a 3D plot, then trace the event and redraw entry points to determine whether redraw re-emits the click event. Done means the documented or corrected behavior no longer causes the recursive loop and is covered by an appropriate regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100