-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Fix Nodes' Positions? NodePosition? is not working #322
Comments
same thing here |
Look here how to build the node object inside a custom layout in order to position the nodes.
|
Issue still relevant. When you provide position key in a Node object the lib set it to 0 anyway. I think the problem is there : createGraph(): void { this.graph = { draw(): void { |
@matndev could you create a stackblitz where this can be reproduced please? Will make it easier for us to see the issue and debug. |
@marjan-georgiev See stackblitz example here: https://stackblitz.com/edit/ngx-graph-demo-cqnamk?file=src/app/data.ts The problem indeed could be originated by the sole initialization of position to { x: 0, y: 0} like @matndev mentioned. |
I need to rearrange nodes per drag 'n drop and save their positions. |
Any updates to this issue? I also need to save the nodes' positions, but initiating the object with the coordinates don't work. |
Hi, until the PR (#463) is merged you can come around the issue, by adding a directive to the Component which overwrites the createGraph function. There you just use the function which is provided in the PR + some rewrites for, this to the component and the id function which is not public. (But just use the code)
Afterwards you can create your own "Layout" which is just an extension of the existing one, but does not use the "layout" function which places the nodes, but rather just recalculates the egdes.
By adding this layout to ngx-graph and the workaround above you can now position the nodes on your "own". Hope this helps. |
Released in 8.0.3 |
@marjan-georgiev - just out of curiosity - is there a way to set the position of nodes without the Layout overriding that position? I've tried a variety of techniques to get the NodePosition in Node to be set such that it would be passed along to the D3Node x + y fields - but it seems like the layout (exp dagre) always just stomps on that. I guess in ngx-graph terminology - is there a "none/null" layout - so that your Node positions actually get preserved? |
It was my solution. Initially, I don't have the nodes starting positions, so I let my custom layout call layout function. The next times, the custom layout uses the already defined nodes positions, and does not call layout function. Very thanks! |
I am trying to fix the position of nodes but I could not do so. I tried using NodePosition property from Node model but it has no effect even if I give it 0 or 100 or 1000.
Please Can anybody help?
The text was updated successfully, but these errors were encountered: