Skip to content
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

Force graph doesn't have force physics after rendering #393

Closed
mossy426 opened this issue May 24, 2024 · 14 comments
Closed

Force graph doesn't have force physics after rendering #393

mossy426 opened this issue May 24, 2024 · 14 comments

Comments

@mossy426
Copy link

This might be a misunderstanding, but we have properties for "force" in the layout settings like so:

type GraphForceLayoutSettings = {
  /** Preferred Link Distance. Default: `60` */
  linkDistance?: number;
  /** Link Strength [0:1]. Default: `0.45` */
  linkStrength?: number;
  /** Charge Force (<0 repulsion, >0 attraction). Default: `-500` */
  charge?: number;
  /** X-centring force. Default: `0.15` */
  forceXStrength?: number;
  /** Y-centring force. Default: `0.25` */
  forceYStrength?: number;
}

And we also have the "fixNodePositionAfterSimulation" property within that as well.

It doesn't seem to matter if you set fixNodePositionAfterSimulation to true or false. Even in the gallery you guys have, the nodes are always fixed. It seems the only force for a force graph is upon initialization of the graph, otherwise everything is pinned and not acted on by forces.

In our Microbetrace application, you can change the charge, force strength, etc. of the network at any time. Is this not possible in Unovis?/Are all nodes pinned after instantiation regardless of whatever layout you choose?

Might be more of a discussion than an issue, but please let me know :)

@rokotyan
Copy link
Contributor

@mossy426 Can you please tell which version of Unovis do you use?

We had a bug in the code that has been fixed in one of the latest betas but didn't make it to the main release yet.

@mossy426
Copy link
Author

mossy426 commented May 30, 2024

All good! I'm using the 1.4.1 build. Should I switch to another?

@rokotyan
Copy link
Contributor

@mossy426 It turned out that 1.4.1 doesn't contain the fix that was published in 1.4.1-alpha.8. We'll be releasing 1.4.2 soon. In the meantime, can you please check if it work on 1.4.1-alpha.8 for you?

@mossy426
Copy link
Author

mossy426 commented Jun 4, 2024

@rokotyan I updated the environment on stackblitz for a quick test to use 1.4.1-alpha.8 for both packages and it appears to still not work, even with fixNodePositionAfterSimulation set to false. https://stackblitz.com/edit/angular-zyybxk?file=src%2Fforce-graph%2Fforce-graph.component.ts

@rokotyan
Copy link
Contributor

rokotyan commented Jun 4, 2024

Thanks @mossy426! I think I know what was causing this. I've just published new package versions 1.4.2-alpha.2 to test. They should fix the problem

@mossy426
Copy link
Author

mossy426 commented Jun 5, 2024

Great! Thanks, please let me know when I can try it out

@rokotyan
Copy link
Contributor

rokotyan commented Jun 5, 2024

@mossy426 Strange, NPM shows it's there. Let's wait a bit and I'll try to release another version if it still doesn't work.

image SCR-20240604-pium

@mossy426
Copy link
Author

mossy426 commented Jun 5, 2024

Interesting, yes it might take a bit I guess? I'm getting an unable to resolve package error when trying that. I'll check back later.

@mossy426
Copy link
Author

mossy426 commented Jun 6, 2024

@rokotyan Ok I was able to download both packages for 1.4.2-alpha.2. It still seems like the nodes are all fixed on load. Stackblitz for reference in case I'm missing something:

https://stackblitz.com/edit/angular-zyybxk?file=src%2Fforce-graph%2Fforce-graph.component.ts

@rokotyan
Copy link
Contributor

rokotyan commented Jun 6, 2024

@mossy426 Thanks, investigating

@rokotyan
Copy link
Contributor

@mossy426 I've tried your example on my end with different fixNodePositionAfterSimulation values and here is what I see

fixNodePositionAfterSimulation: true

Screen.Recording.2024-06-10.at.14.10.53.web.mp4

fixNodePositionAfterSimulation: false

Screen.Recording.2024-06-10.at.14.15.18.web.mp4

Can you please tell us a bit more about what behavior you're expecting?

@mossy426
Copy link
Author

mossy426 commented Jun 11, 2024

@rokotyan Oh wow ok I'm sorry I should have clarified better. I mean with the force graphs in d3 we are using, the forces are always active. Here the forces are only active on load and then all the nodes become fixed, or unaffected by forces and stay in place now matter how you move other nodes around.

For instance, in the force graph I'm talking about, if we were to take a node and move it around the network, you would see the surrounding nodes kind of move out of the way and readjust due to the forces the nodes give off.

Here the nodes are fixed in that no forces affect them after launch. If they weren't fixed, I could then adjust the forces like link strength, center force, etc. in a variety of ways that would animate and help shape the network to what the user is looking for much more easily.

Does that make sense?

@rokotyan
Copy link
Contributor

@mossy426 Ah, I get it now, thanks for the clarification!

We intentionally disabled animated force layout because:

  1. With the level of detail our nodes have, real-time updates can be slow, especially on old hardware;
  2. While the force simulation animation looks nice, we couldn't find the actual use case for it.

In your specific case, if you adjust the forces, you should still be able to see the updated layout on the graph. However, the animation won't look as organic as the force layout generally does because the node positions are simply interpolated between the two states. Or are you experiencing issues with this too?

@mossy426
Copy link
Author

Got it, thanks! We should be good. I'll let you know if we need anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants