垂直排序的节点在D3中的Sankey图 [英] Vertical sort of nodes in D3 Sankey diagram

查看:296
本文介绍了垂直排序的节点在D3中的Sankey图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在此示例的基础上实现一个基本的sankey图:



在这种情况下我想永远保持A在顶部。



有关如何做的任何想法?



同样的问题: D3 sankey图 - 强制执行节点位置

解决方案

您可以修改此函数:

 函数中心(节点){
return node.y + node.dy / 2;
}

就像这样:

 函数中心(节点){
return 0;
}

,然后修改ascendingDepth的函数,如下所示:

 函数ascendingDepth(a,b){
return by - ay;
}

我在另一个问题中发现了这个问题
如何在d3 sankey插件中强制一个分支的y位置? / a>


I'm trying to achieve a basic sankey diagram building on top of this example: http://bl.ocks.org/d3noob/c9b90689c1438f57d649

By default they get sorted by value. I want to customize the vertical order of the nodes. Here is an example:

In this case I'd like to always keep "A" on top.

Any thoughts on how to do that?

Similar question: D3 sankey diagram - enforce node position

解决方案

You can modify this function:

function center(node) {
  return node.y + node.dy / 2;
}

like this:

function center(node) {
   return 0;
}

and after modify ascendingDepth's function like this:

function ascendingDepth(a, b) {
  return b.y - a.y;
}

I found this in another question How to force y position of one branch in d3 sankey plugin?

这篇关于垂直排序的节点在D3中的Sankey图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆