tomshanley / d3-sankey-circular

A fork of the d3-sankey library to allow circular links.
MIT License
89 stars 41 forks source link

Allow links that span columns to be routed away from other nodes #25

Open tomshanley opened 6 years ago

tomshanley commented 6 years ago

Currently, non-circular links that connect nodes which aren't in consecutive columns sometimes overlap other nodes which are in between. While the current functions tries to shift the overlapping nodes out of the way, its not always optimal and causes the layouts the be erratic when slightly changing other parameters.

tomshanley commented 6 years ago

Provide users with an option to route links away from other nodes that are in between the source and target

tomshanley commented 6 years ago

https://github.com/ricklupton/d3-sankey-diagram/ uses the concept of dummy nodes, which could provide a solution, in that these could be used when creating the links, as the layout is strong on preventing node overlaps in the same column

Example process:

  1. identify non-circular links that span more than 1 columns
  2. for each intermediary column
    • create placeholder node(s)
    • identify it as a placeholder
    • create link from source to node
    • identify it as a placeholder [- create link from node to node]
    • identify it as a placeholder
    • create link from node to target
    • identify it as a placeholder
    • delete original link
  3. layout
    • err placeholder nodes for same link to be in line
  4. create the original link, using placeholder links to create path data for original link
  5. delete placeholder links
  6. delete placeholder nodes