Javascript d3中Sankey节点的X位置
因为这是一张显示损耗的图表;我希望将节点垂直堆叠,以便在最右侧只有3个节点,并且在流程的每个级别上,节点应该堆叠在彼此的顶部。我不明白为什么它们都聚集在右边 我想问题出在我正在使用的插件的computeNodeBreaths函数中,但我不知道如何修复它 函数computeNodeReadths(){ var remainingNodes=节点, 下一个节点, x=0Javascript d3中Sankey节点的X位置,javascript,d3.js,visualization,Javascript,D3.js,Visualization,因为这是一张显示损耗的图表;我希望将节点垂直堆叠,以便在最右侧只有3个节点,并且在流程的每个级别上,节点应该堆叠在彼此的顶部。我不明白为什么它们都聚集在右边 我想问题出在我正在使用的插件的computeNodeBreaths函数中,但我不知道如何修复它 函数computeNodeReadths(){ var remainingNodes=节点, 下一个节点, x=0 while (remainingNodes.length) { nextNodes = []; remainingNode
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;
}
while(remainingNodes.length){
nextNodes=[];
remainingNodes.forEach(函数(节点){
节点x=x;
node.dx=节点宽度;
node.sourceLinks.forEach(函数(链接){
if(nextNodes.indexOf(link.target)<0){
nextNodes.push(link.target);
}
});
});
剩余节点=下一个节点;
++x;
}
如有任何建议,将不胜感激
谢谢