plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.9k stars 1.85k forks source link

Sankey nodeAlign? #1938

Closed dangerismycat closed 9 months ago

dangerismycat commented 7 years ago

Curious if there are any plans to merge the more recent d3-sankey support for node alignment (from this commit, June 13 of this year) into your fork? It's a really useful feature that I'd love to be able to use with your great wrapper.

etpinard commented 7 years ago

cc @monfera

monfera commented 7 years ago

@etpinard please tell me when to schedule it:

Some of our PRs to upstream d3-sankey were merged by Mike Bostock, so catching up makes sense for multiple reasons. One of our PRs predictably wasn't taken up, we'll need to reapply, likely not a lot of divergence yet. The alignment options should be exposed via plotly.js attributes in the JSON.

etpinard commented 7 years ago

please tell me when to schedule it:

Definitively not a high priority for now, unless @jackparmer thinks otherwise.

jackparmer commented 7 years ago

Yeah, no customers on my radar who are asking about this. Probably shelve for now.

phillyo commented 6 years ago

would be great to have this option! when visualizing process flows, it makes no sense that the terminal nodes are all on the right of the viz (as for those which did not pass the whole process, they should not be on the same level as all the nodes which did).

harisbal commented 5 years ago

Would be a very welcome addition indeed :) Not being able to control the position of nodes in the sankey diagram is unfortunately a big limitation to their use

antoinerg commented 5 years ago

@harisbal How much control do you want to have over the position of the nodes. Would it be convenient if you could specify the x and y position of each node?

harisbal commented 5 years ago

@antoinerg controlling doesn't sound like a bad idea indeed. What I was thinking though is being able to control the number of "vertical" groups if that makes sense. For instance in the following example sankey_nodes I cannot place the "International aviation" node at the same vertical level as "Electricity grid" and "District heating" (in the picture I'm dragging it manually) Ideally I would like to control how to group nodes (e.g. with a dictionary). In the very nice implementation of ricklupton https://nbviewer.jupyter.org/github/ricklupton/ipysankeywidget/blob/master/examples/More%20examples.ipynb this is called rank sets Thank you very much for checking on this.

JeroenSchmidt commented 5 years ago

@harisbal thank you for the link showing how to use ranksets. This is a really handy feature when one wants to order their sankey data according to a temporal layout - for example when plotting the evolution of communities that appear and disappear over time.

harisbal commented 5 years ago

@JeroenSchmidt that;s exactly the issue I'm facing, where I try to depict some temporal data (often disappearing between nodes).

antoinerg commented 5 years ago

@JeroenSchmidt @harisbal Thank you for reminding me of the need for this worthwhile feature.

In the meantime, PR https://github.com/plotly/plotly.js/pull/3583 (set to be released in 1.46.0) allows one to manually control the position of nodes either via dragging or by setting attributes node.(x|y). I am investigating providing control over the number of colums and ordering within them.

gabubellon commented 5 years ago

I endorse how interesting this feature would be. I have work with d3 / d3-sankey "vanilla" and had problems with depth that in Plotly were solved. However having a nodeAlign implementation for time series would help a lot. Mainly to align the roots (eith no target links) more effectively.

evan-rash commented 5 years ago

@antoinerg are there any updates on plans for specifying number of columns and ordering of nodes within those columns?

ryankinsey1 commented 5 years ago

I'm interested in this as well. What I would like to be able to is have 'terminal nodes' in the middle (i.e. some data flows end in the middle while other's flow through to the end and/or break down into further subgroups.)

piccinnigius commented 4 years ago

@antoinerg any update or trick to implement this? i want to put the terminal nodes by levels (aligned to left instead to right)

this: image

instead of this: image

it's bad to show this kind of things in production... oooooooor how can export the full sankey data with fixed positions?

thanks so much for help!

antoinerg commented 4 years ago

This feature should not be hard to implement since it is supported in our dependencies. I started a branch a while ago https://github.com/plotly/plotly.js/compare/sankey2-node-align that shows what needs to be done. After resolving the conflicts, it might be good to go. I don't have the time to work on this at the moment but I can revisit later of help someone make a PR.

tanvi-cota commented 4 years ago

Do we have any update on this feature? Are we looking to work on this soon? This is a good feature, and already available in our dependency.

nicolaskruchten commented 4 years ago

No one from the Plotly team is working on this at the moment but we’d be happy to accept a PR if someone wants to take Antoine’s work over the finish line :)

tanvi-cota commented 4 years ago

@nicolaskruchten I would love to contribute, let me see how can i get that updated.

jackparmer commented 4 years ago

This issue has been tagged with NEEDS SPON$OR

A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.

Sponsorship range: $5k-$10k

What Sponsorship includes:

Please include the link to this issue when contacting us to discuss.

KaranTrivedi commented 1 year ago

Bump on this issue? \

ghost commented 7 months ago

Hi everyone, I saw an 'align' property was added in plotly v5.19.0 to solve this issue. Unfortunately I can't make it work. I can try any of the 4 values ['center', 'right', 'left', 'justify'], but nothing will change. I tried with the same example as in the plotly sankey tutorial. I have the latest plotly version v5.19.0

Thank you for your help @adamreeve @archmoj

bverem commented 6 months ago

Same, tutorial examples in v5.19.0 are ignoring node alignment values. x and y values for nodes appear to also be ignored (EDIT: It looks like if y=0, the values are ignored, but non-zero y works). Thank you for the help--love the Sankey option!