mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
Updated intersection calculations , Mermaid version 11.0.0-b.64
This commit is contained in:
@@ -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",
|
||||
|
@@ -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];
|
||||
};
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user