[英]Treemap highlighting child-nodes D3
I am experimenting with http://jsfiddle.net/fVJBA/ and trying to get highlighting on the child-nodes on hover over.我正在尝试使用http://jsfiddle.net/fVJBA/并尝试在悬停时突出显示子节点。 In the above example we have drawn child nodes on top of parent node.
在上面的例子中,我们在父节点的顶部绘制了子节点。 My query is to achieve a similar effect as http://www.nytimes.com/packages/html/newsgraphics/2011/0119-budget/ .
我的查询是要达到与http://www.nytimes.com/packages/html/newsgraphics/2011/0119-budget/类似的效果。 I tried adding:
我尝试添加:
g.selectAll(".child")
.data(function(d) { return d.children || [d]})
.enter().append("rect")
.attr("class", "child")
.style("fill", function(d) { return d.children ? color(d.color) : color(d.color); })
.call(rect);
But that didn't seem to do the trick.但这似乎并没有奏效。 Any idea/suggestions?
任何想法/建议? All I need is to show the child name/value when we hover over the parent on top of which we have drawn child nodes?
当我们将鼠标悬停在绘制了子节点的父节点上时,我所需要的只是显示子名称/值?
I achieved this by adding : .on("mouseover", function(d) { console.log(d.value) })
on .child
and removing the g.append("rect") .attr("class", "parent") .call(rect) .append("title")
.我通过添加实现这一点:
.on("mouseover", function(d) { console.log(d.value) })
上.child
并除去g.append("rect") .attr("class", "parent") .call(rect) .append("title")
。
This helps to fetch the child nodes and removes the select from the parent container.这有助于获取子节点并从父容器中删除选择。 Hope this helps someone working on this issue.
希望这可以帮助解决此问题的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.