| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I'm going to change the target branch from master to our upcoming major version branch, v4.0. We've made some changes in the Sankey code and I'd like to add your changes against that. If you have time, it would be great to get this in for that version. I'll leave you a review tomorrow. |
Sorry, something went wrong.
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 v4.0 for the moment) |
Sorry, something went wrong.
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
Sorry, something went wrong.
Good idea, I changed it accordingly. |
Sorry, something went wrong.
Sorry, something went wrong.
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.
Sorry, something went wrong.
…add mocks for link and node sort with reverse
✔
✔
Is already in my v4.0, based on the mocks there is the question how you would like the sorting in reverse mode (see mocks in last commit). Currently links and nodes get sorted as follows: in horizontal and horizontal reverse mode sorted top to bottom while flow goes horizontally; and in vertical and vertical reverse mode sorted left to right while flow goes vertically. Is this ok, or do you want the sorting to always be in direction of flow (i.e. if looking in flow direction, nodes/links should be sorted from left to right)? Status Quo:
|
Sorry, something went wrong.
|
I just noticed that it looks like you committed the diff image files for some of the new mocks. Could you remove those and add the non-diff images? It might be as simple as renaming the diff files. |
Sorry, something went wrong.
|
Apparently my earlier comment never got posted. I played around with the sorting and I think that it's working correctly right now. @adamreeve might have an opinion on this. Additionally, I've got two requests:
|
Sorry, something went wrong.
|
Ah sorry, working too early leads to errors :( I have changed to reversed, added it to mock titles and tried to clean up the baseline images. Reversed baselines will fail, as the title changed. I will re-commit them once the checks have given me new baselines. |
Sorry, something went wrong.
…titles, fix mock and baseline names
|
This looks good to me thanks @wf-r. You might want to update the PR title and description to reflect the changed approach.
This behaviour seems most intuitive to me. And it's easy enough to reverse the order of the nodes if someone wants the opposite. |
Sorry, something went wrong.
|
Done. I hope tests will run successfully now (baselines should be fixed, jasmine as well; yet there are some pixel deviations on my windows machine). Let's see what CI says. |
Sorry, something went wrong.
… with 'reversed')
|
I have to fix one test, will do it this evening (European time). Edit: Done |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for your work on this! It will get released as part of v4.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Add direction attribute to Sankey traces
See #7865
Summary
Adds a new direction attribute (forward / reversed) to the Sankey trace, controlling the flow direction along the existing orientation axis (h / v). This replaces an earlier draft of this feature that overloaded orientation with four values (left-right, right-left, top-down, bottom-up) — see Design history below for why that approach was dropped.
orientation stays exactly as it is today (['v', 'h'], default 'h'). direction is a new, independent, opt-in attribute — fully backward compatible, default 'forward' reproduces current behavior unchanged.
Motivation
Users building dashboards with a fixed narrative direction (e.g. "building things up bottom to top", or RTL-language layouts) currently have no way to mirror a Sankey diagram without manually reversing source/target in their data. direction makes this a pure presentation setting.
Design history — why not four orientation values?
An earlier iteration of this feature added left-right / right-left / top-down / bottom-up as new orientation enum values, with h/v kept as aliases for the two "forward" cases. Review feedback pointed out that this conflates two orthogonal concepts — axis (h/v) and flow direction (forward/reversed) — into a single flag, which doesn't match how similar Plotly attributes are modeled elsewhere (e.g. polar.angularaxis.direction, pie.direction).
The underlying transform geometry is unchanged from the original draft; only the naming/condition changed.
Implementation
The group-level SVG transform in sankeyTransform() mirrors the layout with a single matrix + translate per combination:
Arrows are part of the link path geometry in the same transformed frame, so they mirror correctly and keep pointing at the target with no special handling. Node-label glyphs need a counter-transform (flipText) so they stay upright; the horizontal-reversed case also flips the outer-side text-anchor.