-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Sankey: add attributes node.(x|y)
#3583
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
Conversation
One thing I dislike about the current branch is that I am thinking we might want to add a new attribute cc @alexcjohnson @plotly/plotly_js |
When you drag nodes around by GUI, the others slide around to avoid overlaps. What if we did the same here? You provide positions but then we slide them around, keeping the ordering fixed, to avoid overlaps. It would still have some weird aspects, like if you're on a column that doesn't span the whole height and you want the nodes clustered in certain places you'd have to artificially squish them and trust us to sort it out.
|
Thank you @alexcjohnson for the quick reply! I will give this a bit more thought. In the meantime, here are a few comments:
If the arrangement is If we decide to get rid of overlapping nodes, I could definitely try to implement your suggestion:
Finally,
You're right: it should be a top-level attribute (ie. |
Ah OK, I guess I hadn't seen the interaction modes that allow overlaps to persist. In that case those should still be allowed, and should play nice with explicit positioning. But seems to me the default mode should be to respect explicit positioning but then push apart overlaps. |
node.(x|y)
node.(x|y)
Issue #3563 is also present for arrangement |
@alexcjohnson After the nodes are pushed apart in |
I elected to not update |
Will this work with |
@antoinerg what's the status on this one? Are planning on adding anything else to this PR? |
"data": [ | ||
{ | ||
"type": "sankey", | ||
"arrangement": "freeform", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all the possible values of arrangement
have an effect of the node layout when node.x
and node.y
are set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all the possible values of arrangement have an effect of the node layout when node.x and node.y are set?
Short answer: only snap
can override node.(x|y)
Long answer:
When node.(x|y)
is set, the nodes are forced to sit at the specified locations except in the snap
arrangement. When drag and dropping, snap
is the only arrangement in which we forbid nodes from overlapping so I made sure we keep honoring this promise.
The goal of this PR was to make it possible to replicate any state accessible via drag and drop via node.(x|y)
and hence allowing to export images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the info!
Could we then make arrangement
default to 'freeform'
whenever node.(x|y)
are set? That way, a user that wants to programmatically tweak the node position via node.(x|y)
can do so w/o having to worry about changing the arrangement
value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 65c7201
I wasn't planning on adding anything else to this PR. It is bigger than I initially anticipated and I don't want to complicate it further at this stage. |
Nicely done 💃 💃 |
This closes parts of #2520.
It adds attributes
node.(x|y)
to specify the position of nodes.Upon reordering the nodes by dragging them with the mouse, we update those attributes to persist the state. This allow saving the current state of the figure to an image whereas it used to always export the initial position of the nodes.
This PR also greatly improves our Sankey tests by testing drag operations for every arrangement! This allowed me to catch a regression as discussed in #3583 (comment) .