Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
D3 Force Directed Graph breaks on zoom

I'm using version 7.3.0 of d3 and I have based my code on this example. My problem is that when I'm zooming in (or out) the layout of the circles breaks and becomes

enter image description here

while initially was like this

enter image description here

The code that implements the zoom is

    const zoomed = d3.zoom()
      .scaleExtent([0, 3])
      .on('zoom', event => {
        graph.selectAll('g').attr('transform', event.transform);
      });

I have noticed that if I add the following line of code, then it prevents it from breaking.

    const zoomed = d3.zoom()
      .scaleExtent([0, 3])
      .on('zoom', event => {
        graph.selectAll('g').attr('transform', event.transform);

        // This line prevents zoom from breaking
        simulation.restart();
      });

But the downside is that it becomes noticeably slower. Is there a more efficient way to prevent it from breaking like that?

Any help would be appreciated. Thank you

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda