简体   繁体   English

多个元素的D3鼠标悬停

[英]D3 Mouseover for multiple elements

I am trying to highlight some of my svg elements when mouseover at a specific element. 当将鼠标悬停在特定元素上时,我试图突出显示我的某些svg元素。

So, i got elements like one big circle, small circles for every node, a line for every node, a text for every node. 因此,我得到了像一个大圆圈,每个节点一个小圆圈,每个节点一个线,每个节点一个文本的元素。

What I can do is something like this: 我能做的是这样的:

on("mouseover", function(d) {
      d3.select(this)
      .style("fill", '#0da4d3');})

But I want to use the mouseover method for more than the element in which I am adding the code. 但是我想将mouseover方法用于添加代码的元素之外。

For example, when selecting the big root circle, I want to use mouseover for rootcircle, all texts, the lines and all small circles. 例如,当选择大的根圆时,我想将鼠标悬停在根圆,所有文本,线条和所有小圆上。

Use d3 selections . 使用d3 选择 For example, to select all circles: 例如,要选择所有圈子:

on("mouseover", function(d) { d3.selectAll("circle").style("fill", '#0da4d3');})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM