Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get variable attribute in d3

How do I return a specific attribute of a variable using d3?

For example, I want to select an element by mouseover, and pass on the selection to a function, but only if the element's id is a particular name.

Something like this?

d3.select("body").on("mouseover", function(){ 
    if (d3.select(this).attr("id") == "correct") {
        enableInteraction(d3.select(this));
    }
});
like image 444
Amyunimus Avatar asked Apr 25 '12 03:04

Amyunimus


1 Answers

Yes. Select this and then use the usual functions to access properties.

like image 118
Lars Kotthoff Avatar answered Oct 19 '22 12:10

Lars Kotthoff