Skip to content

Commit

Permalink
#4168 Adding the correct offset for the edges
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Mar 1, 2023
1 parent c0dba71 commit a65fb3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/mermaid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mermaid",
"version": "10.0.1-rc.3",
"version": "10.0.1-rc.4",
"description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
"type": "module",
"module": "./dist/mermaid.core.mjs",
Expand Down
15 changes: 11 additions & 4 deletions packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ const getEdgeStartEndPoint = (edge, dir) => {
let source = edge.start;
let target = edge.end;

// Save the original source and target
const sourceId = source;
const targetId = target;

const startNode = nodeDb[source];
const endNode = nodeDb[target];

Expand All @@ -387,7 +391,7 @@ const getEdgeStartEndPoint = (edge, dir) => {
}

// Add the edge to the graph
return { source, target };
return { source, target, sourceId, targetId };
};

/**
Expand Down Expand Up @@ -530,14 +534,17 @@ export const addEdges = function (edges, diagObj, graph, svg) {

const labelEl = insertEdgeLabel(labelsEl, edgeData);

// calculate start and end points of the edge
const { source, target } = getEdgeStartEndPoint(edge, dir);
// calculate start and end points of the edge, note that the source and target
// can be modified for shapes that have ports
const { source, target, sourceId, targetId } = getEdgeStartEndPoint(edge, dir);
log.debug('abc78 source and target', source, target);
// Add the edge to the graph
graph.edges.push({
id: 'e' + edge.start + edge.end,
sources: [source],
targets: [target],
sourceId,
targetId,
labelEl: labelEl,
labels: [
{
Expand Down Expand Up @@ -698,7 +705,7 @@ const calcOffset = function (src, dest, parentLookupDb) {
};

const insertEdge = function (edgesEl, edge, edgeData, diagObj, parentLookupDb) {
const offset = calcOffset(edge.sources[0], edge.targets[0], parentLookupDb);
const offset = calcOffset(edge.sourceId, edge.targetId, parentLookupDb);

const src = edge.sections[0].startPoint;
const dest = edge.sections[0].endPoint;
Expand Down

0 comments on commit a65fb3b

Please sign in to comment.