diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js index 883fbdc896..1f7ebee9f3 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js @@ -320,7 +320,7 @@ export const adjustClustersAndEdges = (graph, depth) => { domId: specialId1, id: specialId1, labelStyle: '', - label: edge.label, + label: '', padding: 0, shape: 'labelRect', style: '', @@ -342,14 +342,16 @@ export const adjustClustersAndEdges = (graph, depth) => { const edge2 = structuredClone(edge); edge1.label = ''; edge1.arrowTypeEnd = 'none'; + edge1.id = e.name + '-cyclic-special-1'; edgeMid.arrowTypeEnd = 'none'; + edgeMid.id = e.name + '-cyclic-special-mid'; edge2.label = ''; edge1.fromCluster = e.v; edge2.toCluster = e.v; - - graph.setEdge(v, specialId1, edge1, e.name + '-cyclic-special'); - graph.setEdge(specialId1, specialId2, edgeMid, e.name + '-cyclic-special'); - graph.setEdge(specialId2, w, edge2, e.name + '-cyclic-special'); + edge2.id = e.name + '-cyclic-special-2'; + graph.setEdge(v, specialId1, edge1, e.name + '-cyclic-special-0'); + graph.setEdge(specialId1, specialId2, edgeMid, e.name + '-cyclic-special-1'); + graph.setEdge(specialId2, w, edge2, e.name + '-cyclic-special-2'); } else if (clusterDb[e.v] || clusterDb[e.w]) { log.warn('Fixing and trixing - removing XXX', e.v, e.w, e.name); v = getAnchorId(e.v); @@ -375,7 +377,7 @@ export const adjustClustersAndEdges = (graph, depth) => { log.trace(clusterDb); // Remove references to extracted cluster - // graph.edges().forEach(edge => { + // graph.edges().forEach((edge) => { // if (isDescendant(edge.v, clusterId) || isDescendant(edge.w, clusterId)) { // graph.removeEdge(edge); // } diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts index 00c026edd1..2d5c6d6eaf 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts @@ -23,8 +23,8 @@ export const labelRect = async (parent: SVGElement, node: Node) => { const rect = shapeSvg.insert('rect', ':first-child'); // Hide the rect we are only after the label - const totalWidth = 0; - const totalHeight = 0; + const totalWidth = 0.1; + const totalHeight = 0.1; rect.attr('width', totalWidth).attr('height', totalHeight); shapeSvg.attr('class', 'label edgeLabel'); @@ -40,6 +40,8 @@ export const labelRect = async (parent: SVGElement, node: Node) => { // } updateNodeBounds(node, rect); + // node.width = 1; + // node.height = 1; node.intersect = function (point) { return intersect.rect(node, point);