如何调整 d3 sankey.js 中的水平节点位置?

How to tune horizontal node position in d3 sankey.js?

我正在尝试使用 d3 sankey.js 绘制一些流程图。 我被困在图中安排节点 x 位置。

t2_a 应与 t2_b 在同一列中,因为它们代表同一时间段的数量。然而,默认情况下,它被放置在给出错误解释的末尾。

我可以手动安排少量节点,但当节点数量增加时,它真的很难。任何帮助或建议将不胜感激。

在 sankey.js 中评论 computeNodeBreadths 中的 moveSinksRight 调用:

  function computeNodeBreadths() {
    var remainingNodes = nodes,
        nextNodes,
        x = 0;

    while (remainingNodes.length) {
      nextNodes = [];
      remainingNodes.forEach(function(node) {
        node.x = x;
        node.dx = nodeWidth;
        node.sourceLinks.forEach(function(link) {
          nextNodes.push(link.target);
        });
      });
      remainingNodes = nextNodes;
      ++x;
    }

    //
    // moveSinksRight(x); <-- comment this
    scaleNodeBreadths((width - nodeWidth) / (x - 1));
  }