D3 - Show/hide Text Of Only Clicked Node
I am trying to show/hide text of a node in D3 on click. I tried using the following code: var node = svg.selectAll('.node') .data(json.nodes) (...) node.on('click', function()
Solution 1:
node
is a selection containing all your groups (I suppose they are groups, since you didn't copy/paste the entire selection).
If you want to do anything only in the clicked group, you have to select it using d3.select(this)
, which selects the current (in your case, the clicked) DOM element.
Thus, instead of:
node.select("text")
It should be:
d3.select(this).select("text")
Post a Comment for "D3 - Show/hide Text Of Only Clicked Node"