要素に固有の CSS アクセス可能な識別子がある場合は、セレクターを使用できます。:not()
いくつかの潜在的な例:
d3.selectAll("circle.prospect:not(#" + this.id + ")");
d3.selectAll("circle.prospect:not(." + someUniqueClassFrom(d) + ")");
d3.selectAll("circle.prospect:not([uniqueAttr=" + this.getAttribute('uniqueAttr') + "])");
d3.selectAll('circle.prospect:not(this)')
機能しない理由は、文字通り、<this></this>
要素を除外するように言っているだけだからです。これは明らかにあなたの意図ではなく、すでに<circle></circle>
要素のみを選択しているため、関係なく効果はありません。
通常、一意の DOM 属性を適用しない場合でも、一時的に設定できない理由はありません。
vis.selectAll('circle.prospect')
.on("mouseover", function(d) {
this.id = 'temp-' + Math.random();
d3.selectAll('circle.prospect:not(#' + this.id + ')').transition().style('opacity','0.5');
d3.select(this).attr('opacity','1.0');
this.id = '';
});
とはいえ、要素に ID がまだ割り当てられていない場合は、この一時的な識別子ハックの代わりに Ian Roberts のソリューションを使用することをお勧めします。