3D plot redraw() inside a listener cause a recursive loop
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 18.3k
- Forks
- 2k
- Merge moyen
- 2 j 12 h
- PR mergées (30 j)
- 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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Aucun fichier ni test n’est nommé. Commencez par reproduire le listener plotly_click fourni avec Plotly.redraw sur un graphique 3D, puis suivez les points d’entrée de l’événement et de redraw afin de déterminer si redraw réémet l’événement de clic. C’est terminé lorsque le comportement documenté ou corrigé ne provoque plus la boucle récursive et est couvert par un test de régression approprié.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100