From 3e57dbc9164ede88e9164bcd6577939cd63c2eb6 Mon Sep 17 00:00:00 2001 From: Lutz Roeder Date: Sat, 14 Sep 2024 13:58:54 -0700 Subject: [PATCH] Update grapher.js (#1355) --- source/grapher.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/grapher.js b/source/grapher.js index 3001502a4d..b7369b269d 100644 --- a/source/grapher.js +++ b/source/grapher.js @@ -108,7 +108,6 @@ grapher.Graph = class { const element = document.createElementNS('http://www.w3.org/2000/svg', 'g'); element.setAttribute('id', name); element.setAttribute('class', name); - origin.appendChild(element); return element; }; @@ -191,6 +190,18 @@ grapher.Graph = class { edge.label.build(document, edgePathGroup, edgeLabelGroup); this._focusable.set(edge.label.hitTest, edge.label); } + origin.appendChild(clusterGroup); + origin.appendChild(edgePathGroup); + origin.appendChild(edgeLabelGroup); + origin.appendChild(nodeGroup); + for (const edge of this.edges.values()) { + if (edge.label.labelElement) { + const label = edge.label; + const box = label.labelElement.getBBox(); + label.width = box.width; + label.height = box.height; + } + } } measure() { @@ -857,9 +868,6 @@ grapher.Edge = class { this.labelElement.setAttribute('id', `edge-label-${this.id}`); } edgeLabelGroupElement.appendChild(this.labelElement); - const edgeBox = this.labelElement.getBBox(); - this.width = edgeBox.width; - this.height = edgeBox.height; } }