mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-08 01:56:42 +02:00
Updated calculateIterations for ipsepcola layout
This commit is contained in:
@@ -33,19 +33,7 @@ export async function render(data4Layout: LayoutData, svg: SVG): Promise<void> {
|
||||
// assign initial coordinates
|
||||
assignInitialPositions(100, 130, data4Layout);
|
||||
|
||||
const nodesCount = data4Layout.nodes.length;
|
||||
const edgesCount = data4Layout.edges.length;
|
||||
|
||||
const groupNodes = data4Layout.nodes.filter((node) => {
|
||||
if (node.isGroup) {
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
let iteration = nodesCount + edgesCount;
|
||||
if (groupNodes.length > 0) {
|
||||
iteration = iteration * 5;
|
||||
}
|
||||
const iteration = calculateIterations(data4Layout);
|
||||
|
||||
applyCola(
|
||||
{
|
||||
@@ -81,3 +69,21 @@ function sortGroupNodesToEnd(nodes: Node[]): Node[] {
|
||||
|
||||
return [...nonGroupNodes, ...groupNodes];
|
||||
}
|
||||
|
||||
function calculateIterations(data4Layout: LayoutData) {
|
||||
const nodesCount = data4Layout.nodes.length;
|
||||
const edgesCount = data4Layout.edges.length;
|
||||
|
||||
const groupNodes = data4Layout.nodes.filter((node) => {
|
||||
if (node.isGroup) {
|
||||
return node;
|
||||
}
|
||||
});
|
||||
|
||||
let iteration = nodesCount + edgesCount;
|
||||
if (groupNodes.length > 0) {
|
||||
iteration = iteration * 5;
|
||||
}
|
||||
|
||||
return iteration;
|
||||
}
|
||||
|
Reference in New Issue
Block a user