【发布时间】:2016-10-26 13:07:45
【问题描述】:
几个月前,我尝试过combining Hierarchical Edge Bundling and Radial Reingold–Tilford Tree using d3.js
我从 HEB 开始,试图把它变成一棵树。 事情并没有按照我想要的方式进行,我意识到从一个可折叠的径向树(不是 Reingold Tilford)开始可能会更好,但角度不同。
Here is a JSFiddle of the radial tree
数据模型也发生了变化,因为元素现在有了名称、子元素和导入(链接)。
var flare =
{
"name": "root",
"children": [
{
"name": "test1.parent1","children": [
{"name": "test1.child11","children": [
{"name": "test1.child111"},
{"name": "test1.child112"}
]}
],"imports": ["test2.parent2","test3.parent3","test4.parent4"]
},
{
"name": "test2.parent2","children": [
{"name": "test2.child21"},
{"name": "test2.child22"},
{"name": "test2.child28","children":[
{"name": "test2.child281"},
{"name": "test2.child282"}
]}
],"imports": ["test3.parent3"]
},
{"name": "test3.parent3","imports": ["test4.parent4"]},
{
"name": "test4.parent4","children": [
{"name": "test4.child41"},
{"name": "test4.child42"}
]
}
]
};
要慢慢开始,我想将 Mike Bostock 的 non-interactive Hierarchical edge bundling 与当前的 JSFiddle 结合起来,但请记住,交互将在以后成为其中的一部分。
另外,只有第一级必须有如下所示的链接(父父链接)(我想要的结果):
我目前最大的问题是 HEB 没有“根”,但树以单个项目开头。所以到目前为止我所尝试的一切都导致树的中心变得一团糟。
请注意,树的中心有一个圆圈来覆盖根到级别 1 的链接,因此树从级别 1(父级)开始。
var circle = svg.append("circle")
.attr("cx", 0)
.attr("cy", 0)
.attr("r", diameter - 725.3)
.style("fill", "#F3F5F6")
.style("stroke-width", 0.2)
.style("stroke", "black");
理想情况下,当关卡(未)折叠时,父级之间的链接必须更新,就像节点和关卡之间的链接一样,但这可能会在以后出现,并且在最初获得第一关后可能不会那么困难要显示的链接。此外,如有必要,数据模板可能会更改,但所有 3 条信息(名称、子项和导入)都很重要。
另一种方法是能够将数据更改为不包括根部分,并且它的行为与现在完全相同 也欢迎部分回答。
【问题讨论】:
-
绝对不是重复的,但似乎与this有关。
标签: javascript css json d3.js tree