d3.js,可折叠树 - 如何连接不同的父母与同一个孩子 [英] d3.js, collapsible tree - how to connect different parents with same child
问题描述
因此,我使用 http://bl.ocks.org/mbostock/4339083 创建一个可折叠的树和它的工作原理伟大。
So I am using http://bl.ocks.org/mbostock/4339083 to create a collapsible tree and it works great.
现在的事情是我有一些节点有相同的孩子,所以我想知道是否有任何方式可视化图形以这样的方式,使父母扩展到同一个孩子?
Now the thing is I have some nodes which have the same children, so I want to know if there is any way to visualize the graph in such a way that both the parents expand to the same child?
所以基本上当你展开父节点时,它应该自动扩展其他节点
So basically when you expand the node of a parent it should automatically expand the node of the other parent leading to the same common child, is this possible with any graph?
推荐答案
从你的描述中,我收集你需要可视化有向无环图或DAG。
From your description, I gather you need to visualize directed acyclic graph, or DAG.
树是:
A
|\
B C
/ \
D E
DAG is:
A
|\
B C
\|
D
而且,不幸的是,D3树和集群布局根本不支持那种图。他们的内部算法假定数据结构严格地是一棵树。
And, no, unfortunately, D3 tree and cluster layouts simply don't support that kind of graphs. Their internal algorithms assume that the data structure is strictly a tree.
但是,有一些选项。请参阅以下五个相关问题,了解可能的处理方法:
However, there are some options. Please see these five related questions for possible approaches:
How to layout a non-tree hierarchy with D3
这篇关于d3.js,可折叠树 - 如何连接不同的父母与同一个孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!