Add bottom-up and right-left orientations for Sankey diagrams#7870
Add bottom-up and right-left orientations for Sankey diagrams#7870wf-r wants to merge 8 commits into
Conversation
|
I'm going to change the target branch from |
904f306 to
5ea67d9
Compare
Rebase to v4.
Adjust node label alignment for vertical case (labels below still need work)
Finalize node label alignment for vertical cases
|
Thanks for having a look (I have rebased on |
camdecoster
left a comment
There was a problem hiding this comment.
This is a great addition and pretty simple to add. Could you please separate out the direction config into a second attribute? I added a suggestion. This will require changes to your code elsewhere, but I don't think it will be too much work. Let me know what you think
Good idea, I changed it accordingly. |
camdecoster
left a comment
There was a problem hiding this comment.
Let's stick with the existing location. I'll ask for opinions internally. It could be the case that this should be treated as a bug. If that's the case, it can be addressed in a separate PR.
Could you also take a look at sankey/select.js? I think you'll need to make an update there that also handles the reverse direction.
Lastly, link sort and node sort just landed in the v4 branch (in #7873). How do you think that will affect this PR? I think you'll need to merge those changes to make sure things are working.
| var posX = d.reverse ? | ||
| (d.left ? -(pad + CAP_SHIFT * d.textFont.size) : (d.visibleWidth + pad)) : (d.left ? -pad : (d.visibleWidth + pad + CAP_SHIFT * d.textFont.size)); |
There was a problem hiding this comment.
We try to avoid nested ternaries. Could you refactor this to remove that?


What
See #7865
Adds two new flow directions to Sankey traces and gives the existing horizontal/vertical modes explicit, direction-named aliases, fully backward compatible.
orientationnow accepts:h— horizontal, default (unchanged)left-right— sources left, flow rightward (synonym ofh)right-left— sources right, flow leftward (new)v— vertical (unchanged)top-down— sources top, flow downward (synonym ofv)bottom-up— sources bottom, flow upward (new)Why
So far,
his always left→right andvis always top-down. Right-to-left and build-up (bottom-up) flows are common conventions with no equivalent today. This closes both gaps additively, without changing any existing rendering.Backward compatibility
Purely additive. Existing figures using
h/vrender identically; the default is unchanged.