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

202
Vistas
SVG out of viewBox should be zoomable

Hi I am trying really hard to solve this problem. Initially I have an svg-element and inside of it a g-element to make zooming in D3 also possible in Safari. I append a D3 Force-Directed Graph to that g-element after generating it. Zooming works perfectly fine so far.

The Force-Directed Graphis generated as preserved here: https://observablehq.com/@d3/disjoint-force-directed-graph

Initial svg-element created:

svg.value = d3
    .select("#network")
    .append("svg")
    .attr("width", width)
    .attr("height", height)
    .attr("viewBox", [0, 0, width, height])
    .append("g");

Adding the chart:

d3.select("#network").selectAll("svg g > *").remove();
d3.select("#network").select("svg g").node().append(chart);

And the zoom-function afterwards:

const svgZoom = d3.select("#network svg");

const g = d3.select("#network svg g");

svgZoom.call(
    d3
      .zoom()
      .on("zoom", function () {
         g.attr("transform", d3.zoomTransform(this));
        })
);

Now the issue is that the graph always gets cut. I already tried visibility:visible on each of those elements, still not working. Even if I set a viewBox much bigger than the actual content, or if I set the size of the graph to a minimum, the graph will always get cut to a rectangle.

What I want to accomplish is add the graph full-size and by zooming out the overflowing elements get visible. I do not want to get the height and width of the container and minimize the size of each graph drawn, because some graphs are much bigger than the other ones and I want to keep the initial size of the nodes.

How it currenty looks

Without Zooming Out

Zooming Out

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The graph itself cuts the boundaries, adding overflow:visible to the Force-Directed Graph solved the problem.

about 4 years ago · Juan Pablo Isaza Denunciar
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