Updated intersection calculations , Mermaid version 11.0.0-b.64

This commit is contained in:
Knut Sveidqvist
2024-08-15 12:05:59 +02:00
parent 941a1723d8
commit 2415e8652a
3 changed files with 29 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@mermaid-chart/mermaid",
"version": "11.0.0-b.63",
"version": "11.0.0-b.64",
"description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
"type": "module",
"module": "./dist/mermaid.core.mjs",

View File

@@ -28,12 +28,29 @@ const fixInterSections = (points, startNodeId, endNodeId) => {
return fixedPoints;
};
const calcIntersectionPoint = (node, point) => {
const intersection = node.intersect(point);
const dx = intersection.x - node.x;
const dy = intersection.y - node.y;
let pos = 'l';
// Determine the position of the intersection relative to the node
if (Math.abs(dx) > Math.abs(dy)) {
pos = dx > 0 ? 'r' : 'l'; // Right or left
} else {
pos = dy > 0 ? 'b' : 't'; // Bottom or top
}
return { x: intersection.x, y: intersection.y, pos };
};
const calcIntersections = (points, startNodeId, endNodeId) => {
const startNode = nodeDB.get(startNodeId);
const endNode = nodeDB.get(endNodeId);
// Get the intersections
const startIntersection = startNode.intersect({ x: endNode.x, y: endNode.y });
const endIntersection = endNode.intersect({ x: startNode.x, y: startNode.y });
const startIntersection = calcIntersectionPoint(startNode, { x: endNode.x, y: endNode.y });
const endIntersection = calcIntersectionPoint(endNode, { x: startNode.x, y: startNode.y });
return [startIntersection, endIntersection];
};

View File

@@ -554,6 +554,15 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
// .attr('cx', point.x)
// .attr('cy', point.y);
// });
// lineData.forEach((point) => {
// elem
// .append('circle')
// .style('stroke', 'blue')
// .style('fill', 'blue')
// .attr('r', 3)
// .attr('cx', point.x)
// .attr('cy', point.y);
// });
let url = '';
if (getConfig().flowchart.arrowMarkerAbsolute || getConfig().state.arrowMarkerAbsolute) {