1

I'm trying to use the excellent d3-sankey-diagram library by Rick Lupton to draw a sankey diagram. On the demo page "alignLinkTypes" is used to align links with the same types over nodes, but since November 2017 this keyword does not work any more; https://github.com/ricklupton/d3-sankey-diagram/commits/master/src/sankeyLayout/link-ordering.js. However, it's supposed to be possible to accomplish the same thing using ports.

I've tried to search the readme, the wiki and the source code for an answer, but I haven't found one yet.

Can someone tell me how to align link types like in the demo?

lime
  • 15
  • 4

1 Answers1

1

glad you're finding the library useful! (I'm the author)

Unfortunately, as you've spotted, the demo page is out of date. Here is an example of using the new API (with "ports", which is a more flexible way of controlling alignment) in ipysankeywidget:

function alignLinkTypes(layout, align) {
  return layout
    .sourceId(function(d) { return { id: typeof d.source === "object" ? d.source.id : d.source,
                                     port: align ? d.type : null }; })
    .targetId(function(d) { return { id: typeof d.target === "object" ? d.target.id : d.target,
                                     port: align ? d.type : null }; });
}

If align is true, this tells the layout to consider both the source and type of the link when identifying its start and end points (the old "alignLinkTypes" behaviour); otherwise only the source and target are considered.

ricklupton
  • 354
  • 2
  • 7