Merge pull request #1563 from mermaid-js/bug/1562_arrowheads_in_edges_to_cluster

Bug/1562 arrowheads in edges to cluster
This commit is contained in:
Knut Sveidqvist 2020-07-21 12:55:40 +02:00 committed by GitHub
commit 835a3f6149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 6 deletions

View File

@ -28,4 +28,22 @@ describe('Flowchart v2', () => {
{ flowchart: { diagramPadding: 0 } } { 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 } }
);
});
}); });

View File

@ -107,7 +107,7 @@ export const intersection = (node, outsidePoint, insidePoint) => {
outsidePoint.y === edges.y1 || outsidePoint.y === edges.y1 ||
outsidePoint.y === edges.y2 outsidePoint.y === edges.y2
) { ) {
// logger.warn('calc equals on edge'); logger.warn('calc equals on edge');
return outsidePoint; return outsidePoint;
} }
@ -181,9 +181,18 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph)
logger.trace('inside', edge.toCluster, point, lastPointOutside); logger.trace('inside', edge.toCluster, point, lastPointOutside);
// First point inside the rect // First point inside the rect
const insterection = intersection(node, lastPointOutside, point); const inter = intersection(node, lastPointOutside, point);
logger.trace('intersect', insterection);
points.push(insterection); 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; isInside = true;
} else { } else {
if (!isInside) points.push(point); if (!isInside) points.push(point);

View File

@ -523,7 +523,7 @@ function updateRendererConfigs(conf) {
} }
function reinitialize(options) { 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]) { if (options.theme && themes[options.theme]) {
// Todo merge with user options // Todo merge with user options
options.themeVariables = themes[options.theme].getThemeVariables(options.themeVariables); options.themeVariables = themes[options.theme].getThemeVariables(options.themeVariables);
@ -537,7 +537,7 @@ function reinitialize(options) {
} }
function initialize(options) { function initialize(options) {
console.log(`mermaidAPI.initialize: v${pkg.version} ${options}`); // console.log(`mermaidAPI.initialize: v${pkg.version} ${options}`);
// Set default options // Set default options
if (options && options.theme && themes[options.theme]) { if (options && options.theme && themes[options.theme]) {