admin管理员组文章数量:1394544
How do I implement tooltips on mouse over for links in a D3
directed graph layout? I'm adapting the D3
force example, so setting up node tooltips was straightforward using code like this:
node.append("title")
.text(function(n) {
return n.id;
});
Trying a similar technique with the links didn't result in mouse over tool tips:
var link = svg.selectAll("line.link")
.data(json.links)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) {
return 4;
});
link.append("title")
.text(function(n) {
return n.info;
});
How do I implement tooltips on mouse over for links in a D3
directed graph layout? I'm adapting the D3
force example, so setting up node tooltips was straightforward using code like this:
node.append("title")
.text(function(n) {
return n.id;
});
Trying a similar technique with the links didn't result in mouse over tool tips:
var link = svg.selectAll("line.link")
.data(json.links)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) {
return 4;
});
link.append("title")
.text(function(n) {
return n.info;
});
Share
Improve this question
edited Jun 10, 2014 at 11:07
VividD
10.5k8 gold badges66 silver badges112 bronze badges
asked Nov 3, 2012 at 3:46
softweavesoftweave
1,5452 gold badges17 silver badges28 bronze badges
3 Answers
Reset to default 2You can find different solutions suggested by Mike Bostock on this Google Groups thread "show value when click or move mouse over on d3.svg.line"
I think what you are looking for is a bination of these two answers:
d3js: _on()_ doesn't send the current datum object to the onmouse function
and
Adding tooltip to bar chart generated using svg path
Both have jsFiddles you can play with.
Setting the link title as shown above does result in mouse over tooltips -- iff you let the mouse hover over any portion of the link a couple of seconds.
本文标签: javascriptShow d3layoutforce link tooltip on mouse overStack Overflow
版权声明:本文标题:javascript - Show d3.layout.force link tooltip on mouse over - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744093715a2589896.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论