在sunburst中,我怎样才能让代码选择一个根弧,就在所有弧生成之后?选择弧/元素
例如,代码:
var first_arc = ""
.json("../data/flare.json", function(json) {
var path = vis.data([json]).selectAll("path")
.data(partition.nodes)
.enter().append("path")
.attr("display", function(d) { return d.depth ? null : "none"; })
.attr("d", arc)
.attr("t_name", function(d) {return d.name})
.style("fill-rule", "evenodd")
.on("click", function(d)...
它将作为点击中间弧“d”的“功能”被传递。
(其数据先行在JSON文件)
更新1:更改像这样的代码...
.style("fill-rule", function(d) {
if (first_arc == "") first_arc = d; return "evenodd"})
...解决了这个问题,它返回object
:
name: "flare"
children: Array[10]
...
但这种解决方案看起来不正确,不是一般的。
更新2:我尝试了几种选择,例如:
first_arc = d3.select("[name='flare']")
它通常返回array
:
0: null
length: 1
parentNode: HTMLHtmlElement
__proto__: Array[0]
或 “未定义”
更新3:
first_arc = d3.select("[t_name='flare']")
收益大小为1 array
儿童:
0: SVGPathElement
__data__: Object
,其中__data__
是经过我的对象,但我不能管理,将其选中。
要清楚:你是否想让代码选择元素,还是要求用户单击一个弧并直接处理? – Phrogz 2012-07-27 15:23:14
尝试让代码选择元素,直到电弧生成完成。 – alm 2012-07-27 15:33:08
那我还是不明白你的问题是什么。你可以使用['d3.select()'](https://github.com/mbostock/d3/wiki/Selections#wiki-d3_select)方法。你尝试过吗?如果是这样,你的代码是什么,你得到了什么错误(和你期望的是什么)? – Phrogz 2012-07-27 16:05:01