Skip to content

d3-sankey-circular with grouping #3426

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

Closed
wants to merge 4 commits into from

Conversation

antoinerg
Copy link
Contributor

@antoinerg antoinerg commented Jan 10, 2019

Very rough attempt at closing #3321

This prototype implements grouping via a new group attribute. For now, it can be called via Plotly.restyle.

This PR is based off PR #3406

Live demo: https://codepen.io/anon/pen/gZBMKp

@antoinerg antoinerg changed the base branch from master to sankey-circular January 10, 2019 21:04
@antoinerg antoinerg added the feature something new label Jan 10, 2019
@@ -62,7 +100,7 @@ module.exports = function(trace) {
label: l,
color: hasNodeColorArray ? nodeSpec.color[i] : nodeSpec.color
});
} else removedNodes = true;
} else removedNodes = false;
Copy link
Contributor Author

@antoinerg antoinerg Jan 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d3-sankey already does that downstream (ie. removing unlinked nodes) and it's useful to keep the unlinked nodes if you want to render something associated to them. For example, I use it with d3 to render and animate ghost nodes on grouping.

x1: groupingNode.x1,
y0: groupingNode.y0,
y1: groupingNode.y1,
partOfGroup: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partOfGroup === true means that this node is included in another node and is a children. It looks as if it's unliked and was deleted by the d3-sankey* engines.

var nodes = d.graph.nodes.filter(function(n) {return n.originalX === d.node.originalX;});
var nodes = d.graph.nodes
.filter(function(n) {return n.originalX === d.node.originalX;})
.filter(function(n) {return !n.partOfGroup;});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take the children nodes out of the force simulation

@antoinerg
Copy link
Contributor Author

Implementing grouping is a feature that is orthogonal to implementing circular links. Therefore, the current branch could be rebased off #3355.

@antoinerg
Copy link
Contributor Author

antoinerg commented Jan 14, 2019

This PR shows that grouping is doable with both d3-sankey and its circular variant.

Therefore, I will rebase this branch on master after we merge in #3406.

I will keep this PR open in the meantime but there's no need to review it yet.

@antoinerg antoinerg mentioned this pull request Feb 19, 2019
2 tasks
@antoinerg
Copy link
Contributor Author

Closed in favor of PR #3556

@antoinerg antoinerg closed this Feb 19, 2019
@antoinerg antoinerg deleted the sankey-circular-grouping branch February 19, 2019 17:18
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.

1 participant