How can you add new nodes to a graph using a layout without resetting the positions of all other nodes? #3403
Unanswered
steveHornseyDeveloper
asked this question in
Q&A
Replies: 2 comments 2 replies
-
I've just noticed in my sandbox I was using g6 4.5.0 rather than 4.5.1, I've updated the dependency and https://stackblitz.com/edit/react-hkcunr-puekod now works 🙈 . I'm still curious, does anyone else do something similar, and how? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Not really, the way we do this is that we calculate where we want the new node's position to be ourselves and then add it to the g6 graph.
I think we in a different usecase we use the g6 subgraph layouts method to calculate new positions for many nodes and then add the whole new sub graph to our canvas
Sent from Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Brandon Sansone ***@***.***>
Sent: Monday, October 2, 2023 5:17:08 PM
To: antvis/G6 ***@***.***>
Cc: Steve Hornsey ***@***.***>; Mention ***@***.***>
Subject: Re: [antvis/G6] How can you add new nodes to a graph using a layout without resetting the positions of all other nodes? (Discussion #3403)
Hi @steveHornseyDeveloper<https://github.com/steveHornseyDeveloper> did you ever find a solution to this?
—
Reply to this email directly, view it on GitHub<#3403 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFBTJPGMVHUNAFE7U6HYJDLX5LSIJAVCNFSM5KURRTZ2U5DIOJSWCZC7NNSXTOKENFZWG5LTONUW63SDN5WW2ZLOOQ5TOMJWG4YDSNQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on a graph explorer where you start with a single node and add additional nodes to the original node. The data is directed with a maximum of two edges between each pair of nodes (one for each direction). I'd like to use a dagre layout for this graph, however, there is a requirement that every time a user moves a node, that position should be remembered.
I haven't found a way to add nodes using the dagre layout in a way which positions the new nodes according to the dagre layout without overriding the position of any node a user moved.
The two ways I have been trying to do this are
Using a .changeData() to add new nodes and passing the previous position of all nodes using the preset property.
https://g6.antv.vision/zh/docs/api/graphLayout/dagre#layoutcfgpreset
https://stackblitz.com/edit/react-hkcunr-szq8dg
The preset seems to be ignored and any node which was moved gets reverted to the algorithm's location. see #3392
The other way I've tried is by using a sublayout of the existing node and the nodes to be added. However using a sublayout always positions the nodes in the top left of the graph, even when I specify a 'begin' property.
https://g6.antv.vision/zh/docs/api/graphLayout/dagre#layoutcfgbegin
https://stackblitz.com/edit/react-hkcunr-puekod
I can't seem to get begin to work at all even in a basic example #3402
Does anyone know of a way to use a layout to add new nodes to a graph without resetting the position of any nodes a user has moved?
Beta Was this translation helpful? Give feedback.
All reactions