Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const dagreLayout = (data: Data, options: DagreLayoutOption): Data => {
const source = cloneDeep(data);
// eslint-disable-next-line new-cap
const layout = new G6.Layout.dagre({
type: 'dagre',
...options,
});
layout.init(source);
layout.execute();
return {
nodes: layout.nodes,
edges: data.edges,
};
// graph.positionsAnimate();
};
export default dagreLayout;
nodes.forEach(function(node, i) {
if (i <= 16 && i !== 12) {
newNodes.push(node);
newNodeMap.set(node.id, i);
}
});
// add related edges
edges.forEach(function(edge) {
const sourceId = edge.source;
const targetId = edge.target;
if (newNodeMap.get(sourceId) !== undefined && newNodeMap.get(targetId) !== undefined) {
newEdges.push(edge);
}
});
const subForceLayout = new G6.Layout.force({
center: [ nodes[0].x, nodes[0].y ],
linkDistance: 70,
preventOverlap: true,
nodeSize: 20,
tick: function tick() {
// the tick function to show the animation of layout process
graph.refreshPositions();
}
});
subForceLayout.init({
nodes: newNodes,
edges: newEdges
});
subForceLayout.execute();
}, 1000);
const radialLayout = (data: Data, options: RadialLayoutOption) => {
const source = cloneDeep(data);
// eslint-disable-next-line new-cap
const layout = new G6.Layout.radial({
...options,
});
layout.init(source);
layout.execute();
return {
nodes: layout.nodes,
edges: data.edges,
};
};
export default radialLayout;