-
Notifications
You must be signed in to change notification settings - Fork 258
Filled link path #24
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
Filled link path #24
Conversation
…relying on stroke-width
|
Over the last few days I started to think about
The reason is that the I don't currently see how to geometrically meet two goals simultaneously: 1) multiedges with neither gaps, nor overlaps, 2) constant cross section of individual edges; 3) constant cross section of the aggregation of multi-edges, 4) use of the current spline. It is possible to elaborately create a Therefore the full-on option might be:
Apparently in some version at least, Tableau makes the tradeoff similar to this PR, i.e. apparent 'thinning' of the straight middle section of the links, though similarly not disturbing here due to the not too steep angles (nice use case for multi-edges except the minor discrepancy that the color scale legend is continuous while multi-edges use discrete colors): Any thoughts on this? =================== Btw. is it the good place for discussion? TIL some of the OS maintainers prefer that there's no PR before discussion on an Issue and I've also heard of maintainers who insist on, or prefer a PR with code even for the discussion part. |
|
Sorry, I haven’t been actively maintaining this library recently, and it looks like @arankek hasn’t been, either. I do want to get back to it eventually, but I don’t think I will be able to do that within the next few weeks. |
|
@monfera I was dealing with this a few years ago in my project, and implemented a (hacky) check for link distance vs thickness — if it is large enough then use stroke-based links, otherwise use filled links. This may not be the best approach (and I don't even want to share my condition, it looks odd, I need to review/revise it), but back then I found that for my situation both stroke and fill methods are needed, depending on link size. |
|
@NPC thanks, interesting approach! Maybe you have had a somewhat different set of requirements as probably the code didn't aim to support multi-edges more so than today, see the criss-crossing correct? Undesirable gaps and overlaps appear with multi-edge The conditionalization idea in general is good, e.g. switching to Btw. the |
|
@monfera You are correct, I am not dealing with multi-edge links at all, links between same A & B nodes are summed. That simplified my task, I see now that yours is much more advanced. |
|
I feel it’s important to maintain the constant width of links. If you want to generate a path from the outline of a stroked Bézier curve, I recommend reading Mike “Pomax” Kamermans’ Primer on Bézier Curves, and also using his Bezier.js library which implements offset curves. It should be reasonably straightforward plug the output coordinates from d3-sankey into Bezier.js; see also the implementations of d3.sankeyLinkHorizontal and d3.linkHorizontal for the smooth curves used in the examples. |


Purports to solve these items:
A not particularly useful example, showing alignment of multi-edge link boundaries without gap or overlap (to reproduce the example, merge #19 also):

The same, without styling the link path

stroke, i.e. just the fill:The same, using a translucent black, to better show there are no disturbing gaps or overlaps - the same pairs of nodes are still multi-edges as above, and the nodes are moved vertically to stress test the link curves:

There's also some loss:
stroke-widthbased logic doesn't haveD3, usually code size consideration is important (also, it's in theD3org and made by Mike Bostock but isn't part ofD3proper)stroke-widthinstead of the usuald.link.dy