d3中Sankey节点的X位置

时间:2016-06-29 23:09:08

标签: javascript d3.js visualization

This is my Sankey diagram showing the attrition of sexual assault cases that are reported to the police in New Zealand

This is the data I am drawing from

因为这是一张显示减员的图表;我希望节点垂直堆叠,以便最右边只有3个节点,并且在进程的每个级别,节点应该堆叠在一起。我无法弄清楚为什么它们都在右边聚类。

我认为问题出在我正在使用的插件的computeNodeBreaths函数中,但我无法弄清楚如何修复它。

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) {
      if (nextNodes.indexOf(link.target) < 0) {
        nextNodes.push(link.target);
      }
    });
  });
  remainingNodes = nextNodes;
  ++x;
}

非常感谢任何建议。

由于

0 个答案:

没有答案
相关问题