From cb793028677a954e9be9ccbaae77e335bea914ef Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 21 Jul 2020 12:01:08 +0200 Subject: [PATCH 1/2] #1562 Updated handling of pointsarray when the point is already in the array --- .../integration/rendering/flowchart-v2.spec.js | 18 ++++++++++++++++++ src/dagre-wrapper/edges.js | 17 +++++++++++++---- src/mermaidAPI.js | 4 ++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index 222f8d74c..9644f5703 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -28,4 +28,22 @@ describe('Flowchart v2', () => { { flowchart: { diagramPadding: 0 } } ); }); + + it('3: a link with correct arrowhead to a subgraph', () => { + imgSnapshotTest( + `flowchart TD + P1 + P1 -->P1.5 + subgraph P1.5 + P2 + P2.5(( A )) + P3 + end + P2 --> P4 + P3 --> P6 + P1.5 --> P5 + `, + { flowchart: { diagramPadding: 0 } } + ); + }); diff --git a/src/dagre-wrapper/edges.js b/src/dagre-wrapper/edges.js index 85f7d2849..ce11fdc56 100644 --- a/src/dagre-wrapper/edges.js +++ b/src/dagre-wrapper/edges.js @@ -107,7 +107,7 @@ export const intersection = (node, outsidePoint, insidePoint) => { outsidePoint.y === edges.y1 || outsidePoint.y === edges.y2 ) { - // logger.warn('calc equals on edge'); + logger.warn('calc equals on edge'); return outsidePoint; } @@ -181,9 +181,18 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph) logger.trace('inside', edge.toCluster, point, lastPointOutside); // First point inside the rect - const insterection = intersection(node, lastPointOutside, point); - logger.trace('intersect', insterection); - points.push(insterection); + const inter = intersection(node, lastPointOutside, point); + + let pointPresent = false; + points.forEach(p => { + pointPresent = pointPresent || (p.x === inter.x && p.y === inter.y); + }); + // if (!pointPresent) { + if (!points.find(e => e.x === inter.x && e.y === inter.y)) { + points.push(inter); + } else { + logger.warn('no intersect', inter, points); + } isInside = true; } else { if (!isInside) points.push(point); diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index 74a8ffc64..1b2e91da2 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -523,7 +523,7 @@ function updateRendererConfigs(conf) { } function reinitialize(options) { - console.warn(`mermaidAPI.reinitialize: v${pkg.version}`, options); + // console.warn(`mermaidAPI.reinitialize: v${pkg.version}`, options); if (options.theme && themes[options.theme]) { // Todo merge with user options options.themeVariables = themes[options.theme].getThemeVariables(options.themeVariables); @@ -537,7 +537,7 @@ function reinitialize(options) { } function initialize(options) { - console.log(`mermaidAPI.initialize: v${pkg.version} ${options}`); + // console.log(`mermaidAPI.initialize: v${pkg.version} ${options}`); // Set default options if (options && options.theme && themes[options.theme]) { From b93ef22687ca300a3b698ce180b414910c8bfc37 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 21 Jul 2020 12:31:05 +0200 Subject: [PATCH 2/2] #1562 Fix for test --- cypress/integration/rendering/flowchart-v2.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index 9644f5703..2addd4772 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -45,5 +45,5 @@ describe('Flowchart v2', () => { `, { flowchart: { diagramPadding: 0 } } ); - + }); });