Equivalent of jQuery's 'not' selector in D3.js?

后端 未结 3 1317
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 01:28

Working in D3.js, I\'d like to select all the elements that match a selector except for the current element.

The reason is that I\'d like to mouseover a ci

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 01:55

    You can filter a selection:

    vis.selectAll('circle.prospect')
    .on("mouseover", function(d) { 
         console.log(d);
        var circleUnderMouse = this;
        d3.selectAll('circle.prospect').filter(function(d,i) {
          return (this !== circleUnderMouse);
        }).transition().style('opacity','0.5');
        d3.select(this).attr('opacity','1.0');
      });
    

提交回复
热议问题