3D plot redraw() inside a listener cause a recursive loop
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 18.3k
- Forks
- 2k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 28
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es werden keine Dateien oder Tests genannt. Beginne damit, den bereitgestellten plotly_click listener mit Plotly.redraw auf einem 3D-Plot zu reproduzieren, und verfolge dann die Event- und redraw-Einstiegspunkte, um zu bestimmen, ob redraw das Click-Event erneut ausgibt. Erledigt ist die Aufgabe, wenn das dokumentierte oder korrigierte Verhalten die rekursive Schleife nicht mehr verursacht und durch einen geeigneten Regressionstest abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100