mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-11 11:29: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
|
// assign initial coordinates
|
||||||
assignInitialPositions(100, 130, data4Layout);
|
assignInitialPositions(100, 130, data4Layout);
|
||||||
|
|
||||||
const nodesCount = data4Layout.nodes.length;
|
const iteration = calculateIterations(data4Layout);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
applyCola(
|
applyCola(
|
||||||
{
|
{
|
||||||
@@ -81,3 +69,21 @@ function sortGroupNodesToEnd(nodes: Node[]): Node[] {
|
|||||||
|
|
||||||
return [...nonGroupNodes, ...groupNodes];
|
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