plotly / plotly/plotly.js

3D plot redraw() inside a listener cause a recursive loop

Abierto
#1,025 15 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug P2
Lenguaje dominante
JavaScript
Estrellas
18.3k
Forks
2k
Merge medio
2 d 12 h
PR fusionados (30 d)
28

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

No se nombran archivos ni tests. Empieza reproduciendo el listener plotly_click proporcionado con Plotly.redraw en un gráfico 3D y, a continuación, rastrea los puntos de entrada de eventos y redraw para determinar si redraw vuelve a emitir el evento de clic. Se considera terminado cuando el comportamiento documentado o corregido ya no provoca el bucle recursivo y está cubierto por una prueba de regresión adecuada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
data-visualization
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.