[Feat]: I need help with layout calculation. #6952
-
Describe the feature / 功能描述I am using Antv G6 v4.8.21. In my example scenario, the graph is created and there are 50 nodes and 50 edges in it. Their x and y values are known (calculated by the layout during the first creation) Later, I add 30 nodes and 20 edges to the graph with addItem and what I want is not to recalculate the nodes whose x and y values are determined before, their locations remain fixed. But I want calculations to be made for the nodes and edges added later. Which way would be the best when doing this? 1-) Doing it with pipes (I don't know exactly which order to follow) 2-)layout: { }, 3-) Doing it with a setting like preset:"preset". 4-) or another method? Are you willing to contribute? / 是否愿意参与贡献?✅ Yes / 是 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
A simple method to fix existing node positions while enabling dynamic layout for new nodes: {
layout: {
type: 'force2',
onLayoutEnd: (nodes) => {
nodes.forEach(node => {
node.fx = node.x;
node.fy = node.y;
})
}
} |
Beta Was this translation helpful? Give feedback.
-
|
Really great solution. You are great. Thank you |
Beta Was this translation helpful? Give feedback.
A simple method to fix existing node positions while enabling dynamic layout for new nodes: