d3-plugins
d3-plugins copied to clipboard
Sort sankey target links by descending slope.
Looking at the Sankey example (http://bost.ocks.org/mike/sankey/), nodes like "Road transport" occur frequently which have crossing link lines. This creates unnecessary visual confusion. The problem occurs when a "higher" node is also farther left in the chart which causes the lines to cross as they reach the target. (Other nodes with the problem include "Electricity grid" and "Industry", although these are both more difficult to see in this particular chart.)
Using the link's slope (as if it were a straight line) as a heuristic, we can reduce the number of crossings at the target end.
Before:

After:
