viz: check node exists before anchoring zoom (#16627)

This commit is contained in:
qazal
2026-06-15 20:03:24 +08:00
committed by GitHub
parent f998b9930a
commit 10bdb9c9d0

View File

@@ -187,7 +187,7 @@ function renderDag(layoutSpec, { recenter }) {
}).attr("class", e => e.value.label.type).attr("id", e => `${e.v}-${e.w}`).datum(e => ({ text:e.value.label.text })));
if (anchor != null) {
const n = g.node(anchor.id);
d3.select("#graph-svg").call(svgZoom.transform, d3.zoomIdentity.translate(anchor.x-n.x*anchor.k, anchor.y-n.y*anchor.k).scale(anchor.k));
if (n != null) d3.select("#graph-svg").call(svgZoom.transform, d3.zoomIdentity.translate(anchor.x-n.x*anchor.k, anchor.y-n.y*anchor.k).scale(anchor.k));
} else if (recenter) document.getElementById("zoom-to-fit-btn").click();
anchor = null;
};