admin管理员组文章数量:1388929
I love the way this scatterchart highlights circles when you mouse over them: .html
But there's a lot of code there (looks like the author has defined his/her own standard libraries) and I can't figure out exactly how the effect is achieved.
Is it something to do with the .hover
class and the stroke-width
property?
I'd like to achieve the same effect on my own scatter graph, although I'm using circles rather than paths, so it may not be possible.
I love the way this scatterchart highlights circles when you mouse over them: http://novus.github./nvd3/examples/scatterWithLegend.html
But there's a lot of code there (looks like the author has defined his/her own standard libraries) and I can't figure out exactly how the effect is achieved.
Is it something to do with the .hover
class and the stroke-width
property?
I'd like to achieve the same effect on my own scatter graph, although I'm using circles rather than paths, so it may not be possible.
Share Improve this question asked May 27, 2012 at 8:10 flossfanflossfan 10.9k16 gold badges45 silver badges54 bronze badges1 Answer
Reset to default 8In the example, the effect seems to be realised in scatter.js from line 136.
Just highlighting individual circles is much easier though and doesn't need all the other stuff the example does. All you need to do is add a mouseover
handler to the circles and (for example) increase stroke-width
. That would look something like
d3.selectAll("circle").data(...).enter()
.append(...)
.classed("circle", true)
.on("mouseover", function() { d3.select(d3.event.target).classed("highlight", true); })
.on("mouseout", function() { d3.select(d3.event.target).classed("highlight", false); });
I'm assuming that a CSS class highlight
defines the style. Alternatively, you can just use (in this example) CSS class circle:hover
without the need for the event handlers.
本文标签: javascriptHow is this nice D3js scattergraph highlighting effect achievedStack Overflow
版权声明:本文标题:javascript - How is this nice D3.js scattergraph highlighting effect achieved? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744539102a2611497.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论