Skip to content

Sankey: group nodes #3556

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

Merged
merged 13 commits into from
Feb 26, 2019
Merged

Sankey: group nodes #3556

merged 13 commits into from
Feb 26, 2019

Conversation

antoinerg
Copy link
Contributor

@antoinerg antoinerg commented Feb 19, 2019

Closes part of #3321 by implementing grouping of nodes via a new node.groups attribute. For now, it can be called via Plotly.restyle.

It is based off a recent master and it supersedes PR #3426

Checklist:

  • Remove transitions on first render
  • Disallow nodes to be in more than one group

@antoinerg
Copy link
Contributor Author

Here's a Codepen showcasing the new mock introduced in this PR: https://codepen.io/antoinerg/pen/MLxjmB

@etpinard
Copy link
Contributor

1.45.0 is getting delayed (due to my buggy PRs), so let's try get this in 1.45.0!

@etpinard etpinard added this to the v1.45.0 milestone Feb 21, 2019
@etpinard
Copy link
Contributor

@antoinerg let me know if you need help to finish up this PR today.

@etpinard
Copy link
Contributor

@antoinerg can you fix:

image

?

@etpinard
Copy link
Contributor

Awesome work @antoinerg

Looks like this PR only needs two more interaction tests:

and it will be ready to 🚀

@antoinerg
Copy link
Contributor Author

antoinerg commented Feb 26, 2019

@etpinard I added tests in ffbafa7 as requested. In the process of writing them, I encountered a show-stopping bug for certain combinations of nodes: for example in mock sankey_energy if you try to group nodes 1 and 3:

Plotly.restyle(gd,{'node.groups':[[[1,3]]]})

CPU usage goes to 100% and the operation never ends. The issue seems limited to d3-sankey: it works fine if the underlying Sankey generator is d3-sankey-circular. One way we could deal with this would be to force the use of d3-sankey-circular when node.groups is defined and not empty. That way, we would not have any breaking changes.

I would still like to investigate why exactly d3-sankey chokes the way it does for some combinations of nodes 🤔

@antoinerg
Copy link
Contributor Author

antoinerg commented Feb 26, 2019

The problem mentionned in #3556 (comment) is now fixed in 7094887.

The problem was that the check for circularity was done prior to grouping nodes. Grouping certain combination of nodes (see 1.) can create a circularity and d3-sankey cannot process the resulting graph (hence the infinite loop). By checking for circularity after grouping, we can appropriately switch to d3-sankey-circular.

  1. This is obivous: if we have 1 -> 2 -> 3 and we group 1 and 3, we get 2 <-> 3 which now has a circular link. I should have thought of this 🤦‍♂️

@etpinard
Copy link
Contributor

Nicely done 💃

@antoinerg antoinerg merged commit db54ced into master Feb 26, 2019
@antoinerg antoinerg deleted the sankey2-grouping branch February 26, 2019 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants