mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-14 12:59:46 +02:00
#1436 Correcting intersection calculations for circles
This commit is contained in:
@@ -19,17 +19,17 @@
|
||||
<body>
|
||||
<h1>info below</h1>
|
||||
<div class="mermaid" style="width: 100%; height: 20%;">
|
||||
stateDiagram-v2
|
||||
|
||||
[*] --> S1
|
||||
state "Some long name" as S1: The
|
||||
flowchart TD
|
||||
db[(PostgreSQL<br/>database)]
|
||||
broker{RabbitMQ<br/>broker}
|
||||
db --> broker
|
||||
box --> broker
|
||||
</div>
|
||||
<div class="mermaid" style="width: 100%; height: 20%;">
|
||||
stateDiagram-v2
|
||||
broker --> db
|
||||
broker --> box
|
||||
db --> broker
|
||||
box --> broker
|
||||
|
||||
[*] --> S1
|
||||
state "Some long name" as S1: The description\nwith multiple lines
|
||||
</div>
|
||||
<div class="mermaid2" style="width: 50%; height: 20%;">
|
||||
flowchart LR
|
||||
A{{A}}-- apa -->B{{B}};
|
||||
@@ -59,11 +59,6 @@ graph LR
|
||||
State4 --> [*]
|
||||
}
|
||||
</div>
|
||||
<div class="mermaid mermaid-apa" style="width: 100%; height: 20%;">
|
||||
stateDiagram-v2
|
||||
[*] --> Still
|
||||
Still --> [*]
|
||||
</div>
|
||||
<div class="mermaid2" style="width: 100%; height: 100%;">
|
||||
stateDiagram-v2
|
||||
[*] --> Still
|
||||
|
@@ -116,8 +116,13 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph)
|
||||
|
||||
if (head.intersect && tail.intersect) {
|
||||
points = points.slice(1, edge.points.length - 1);
|
||||
|
||||
points.unshift(tail.intersect(points[0]));
|
||||
logger.info(
|
||||
'Last point',
|
||||
points[points.length - 1],
|
||||
head,
|
||||
head.intersect(points[points.length - 1])
|
||||
);
|
||||
points.push(head.intersect(points[points.length - 1]));
|
||||
}
|
||||
if (edge.toCluster) {
|
||||
|
@@ -93,8 +93,8 @@ const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
|
||||
// Move the nodes to the correct place
|
||||
graph.nodes().forEach(function(v) {
|
||||
const node = graph.node(v);
|
||||
// log.trace('Position ' + v + ': ' + JSON.stringify(graph.node(v)));
|
||||
log.trace(
|
||||
log.trace('Position ' + v + ': ' + JSON.stringify(graph.node(v)));
|
||||
log.info(
|
||||
'Position ' + v + ': (' + node.x,
|
||||
',' + node.y,
|
||||
') width: ',
|
||||
|
@@ -1,5 +1,6 @@
|
||||
module.exports = intersectNode;
|
||||
|
||||
function intersectNode(node, point) {
|
||||
console.info('Intersect Node');
|
||||
return node.intersect(point);
|
||||
}
|
||||
|
@@ -19,6 +19,8 @@ const question = (parent, node) => {
|
||||
{ x: 0, y: -s / 2 }
|
||||
];
|
||||
|
||||
logger.info('Question main (Circle)');
|
||||
|
||||
const questionElem = insertPolygonShape(shapeSvg, s, s, points);
|
||||
updateNodeBounds(node, questionElem);
|
||||
node.intersect = function(point) {
|
||||
@@ -412,10 +414,13 @@ const circle = (parent, node) => {
|
||||
.attr('width', bbox.width + node.padding)
|
||||
.attr('height', bbox.height + node.padding);
|
||||
|
||||
logger.info('Circle main');
|
||||
|
||||
updateNodeBounds(node, circle);
|
||||
|
||||
node.intersect = function(point) {
|
||||
return intersect.circle(node, node.rx, point);
|
||||
logger.info('Circle intersect', node, bbox.width / 2 + halfPadding, point);
|
||||
return intersect.circle(node, bbox.width / 2 + halfPadding, point);
|
||||
};
|
||||
|
||||
return shapeSvg;
|
||||
|
Reference in New Issue
Block a user