Skip to content
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

Inconsistent layout with nodePadding #24

Open
techniq opened this issue Jun 14, 2018 · 6 comments
Open

Inconsistent layout with nodePadding #24

techniq opened this issue Jun 14, 2018 · 6 comments
Assignees

Comments

@techniq
Copy link

techniq commented Jun 14, 2018

Hi @tomshanley,

I'm looking to use d3-sankey-circular to provide a <Sankey> layout component for vx as the support for circular references is great, but when comparing non-circular layouts that d3-sankey produces, d3-sankey-circular's layouts are not as optimal.

One example I've run across is with the handling of nodePadding. With d3-sankey, the layout does not appear to jump around as the nodePadding goes up and down...

d3-sankey

...but with d3-sankey-circular, it's rather eradicate:

d3-sankey-circular

Here is the codesandbox that demonstrates the issue.

@tomshanley
Copy link
Owner

Hi - thanks for the evaluating this library! There is an issue with sankeycircular compared to the original sankey library. sankeycircular has a few more layout 'optimisations', such as trying to avoid overlap of nodes with links that span multiple columns (it'll try to shift nodes to more optiimal heights), and also shifting links within the node's height to avoid overlaps with other links. In addition, I've not optimised these layouts when there's no circular links. These combined, mean that each change of a variable is more likely to produce a quite different layout, as you've seen, compared to the original d3.sankey which has less optimisations, which makes it more consistent.

I need to improve sankeycircular in this regards (perhaps defaulting back to nearly all the original sankey functions where's no circular links detected). Also looking at your example, there's still some sub-optimal layouts (like where the Nuclear node is ending up, as it looks like the optimisation towards straighter links is beating the overlaps)

Also, I am considering how to update a sankey after its drawn (based on different link values, but it could be extended to other variables like nodePadding) so that the layout remains close to the originally drawn sankey (see issue 20). This should help.

Another factor is that I want to drop a hard coded nodePadding pixel value, and replace it with the nodePaddingRatio (something like the padding ratios used in the ordinal axis layouts) so that is scales when the node values update.

I'm not going to be able to fix this soon I'm afraid, as I'll need to review most parts of the layouts.

I work around would be select sankeyCircular only when you have known circular links, which isn't ideal I know

@techniq
Copy link
Author

techniq commented Jun 14, 2018 via email

@tomshanley
Copy link
Owner

Yeah, I know its not ideal to have to support two libraries. Admittedly, I could include the d3-sankey, and sankeyCircular does the test for circular links and then proceed accordingly. I'll try that next time I've got some headspace for this project.

@techniq
Copy link
Author

techniq commented Jun 14, 2018 via email

@tomshanley
Copy link
Owner

tomshanley commented Jun 14, 2018

i may just incorporate the parts that are different and switch based on the presence of circular links. probably wouldn't inflate too much, but I will do a test. initially it may be more, but I'm sure I could find more opportunities to rationalise.

@techniq
Copy link
Author

techniq commented Jun 15, 2018 via email

@tomshanley tomshanley self-assigned this Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants