-
Notifications
You must be signed in to change notification settings - Fork 374
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
d3.forceCenter should have an alpha parameter. #81
Comments
@DavidBruant: do you have a temporary workaround for it? I find it a bit annoying as well when adding and removing nodes. Thanks. |
I think it’d be reasonable to implement an alpha (blend) parameter for d3.forceCenter so that it smoothly shifts to the new center. (Or maybe it could even use the simulation’s current alpha? You’d have to try it and see what works.) For example, each application of the force it would move 20% of the way to the new center. That way there’s a little bit of hysteresis for discontinuous changes such as adding a node. I also think it’s a great idea to use the d3-force keyword to publish additional forces on npm. |
In my experiments having strength = 0.05 and multiplying sx, sy by alpha * strength results in a quite agreeable movement. At this point I don't see the necessity to make it configurable? |
and change x,y not vx, vy. - this makes #81 non-breaking - strength=1 recenters "at once" for non-interactive graphs (or, for example, the initial phyllotaxis layout) - strength=0.05 recenters gently for interactive situations such as https://observablehq.com/d/674136693ce67301
and change x,y not vx, vy. - this makes #81 non-breaking - strength=1 recenters "at once" for non-interactive graphs (or, for example, the initial phyllotaxis layout) - strength=0.05 recenters gently for interactive situations such as https://observablehq.com/d/674136693ce67301
and change x,y not vx, vy. - this makes #81 non-breaking - strength=1 recenters "at once" for non-interactive graphs (or, for example, the initial phyllotaxis layout) - strength=0.05 recenters gently for interactive situations such as https://observablehq.com/d/674136693ce67301 fixes #81
My use case is that I'm building a UI where people can add a node by double-clicking. The node appears where the mouse is.
I tried using
d3.forceCenter
, but when the node appears, it just recenters everything instantly which I find a bit aggressive. I want to provide a smoother experience (the whole graph gradually recenters)Filing this issue for various reasons:
d3-force
keyword?The text was updated successfully, but these errors were encountered: