diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/cose-bilkent/render.ts b/packages/mermaid/src/rendering-util/layout-algorithms/cose-bilkent/render.ts index b95d92360..7ed60e621 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/cose-bilkent/render.ts +++ b/packages/mermaid/src/rendering-util/layout-algorithms/cose-bilkent/render.ts @@ -115,6 +115,18 @@ export const render = async ( } }); + layoutResult.edges.forEach((positionedEdge) => { + const edge = data4Layout.edges.find((e) => e.id === positionedEdge.id); + if (edge) { + // Update the edge data with positioned coordinates + edge.points = [ + { x: positionedEdge.startX, y: positionedEdge.startY }, + { x: positionedEdge.midX, y: positionedEdge.midY }, + { x: positionedEdge.endX, y: positionedEdge.endY }, + ]; + } + }); + // Step 4: Insert and position edges log.debug('Inserting and positioning edges'); @@ -134,10 +146,7 @@ export const render = async ( if (positionedEdge) { log.debug('APA01 positionedEdge', positionedEdge); // Create edge path with positioned coordinates - const edgeWithPath = { - ...edge, - points: positionedEdge.points, - }; + const edgeWithPath = { ...edge }; // Insert the edge path const paths = insertEdge( diff --git a/packages/mermaid/src/rendering-util/types.ts b/packages/mermaid/src/rendering-util/types.ts index 376b37167..46ee50154 100644 --- a/packages/mermaid/src/rendering-util/types.ts +++ b/packages/mermaid/src/rendering-util/types.ts @@ -128,6 +128,7 @@ export interface Edge { thickness?: 'normal' | 'thick' | 'invisible' | 'dotted'; look?: string; isUserDefinedId?: boolean; + points?: Point[]; } export interface RectOptions {