Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 23db7f4

Browse files
Make force graphs resize with viewport
Both the architecture overview and entity force graphs now resize their SVG width and re-center the simulation on window resize (debounced 150ms). Nodes reflow to fill the new canvas.
1 parent 51605d2 commit 23db7f4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

templates/_main.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ window.addEventListener("load", function() {
175175
return "translate(" + d.x + "," + d.y + ")";
176176
});
177177
});
178+
179+
var fgResizeTimer;
180+
window.addEventListener("resize", function() {
181+
clearTimeout(fgResizeTimer);
182+
fgResizeTimer = setTimeout(function() {
183+
width = graphEl.clientWidth || 600;
184+
svg.attr("width", width);
185+
simulation.force("center", d3.forceCenter(width / 2, height / 2 + 10));
186+
simulation.alpha(0.3).restart();
187+
}, 150);
188+
});
178189
}
179190
} catch (e) {
180191
console.error("Force graph error:", e);
@@ -364,6 +375,17 @@ window.addEventListener("load", function() {
364375
return "translate(" + d.x + "," + d.y + ")";
365376
});
366377
});
378+
379+
var aoResizeTimer;
380+
window.addEventListener("resize", function() {
381+
clearTimeout(aoResizeTimer);
382+
aoResizeTimer = setTimeout(function() {
383+
aoW = archOverEl.clientWidth || 800;
384+
aoSvg.attr("width", aoW);
385+
aoSim.force("center", d3.forceCenter(aoW / 2, aoH / 2));
386+
aoSim.alpha(0.3).restart();
387+
}, 150);
388+
});
367389
}
368390
} catch (e) { console.error("Architecture overview error:", e); }
369391
}

0 commit comments

Comments
 (0)