Skip to content Skip to sidebar Skip to footer

How Can I Change Style Class & Content Of Text For Ancestors In This D3.js Tree?

This is a follow-up to this question. (Thanks Cyril for all your help!!) My problem turned out to be a little bit tricker and I still need some help. When the user clicks on a text

Solution 1:

When you traverse up from the node clicked, to the parent root.

You can also get the DOM element (group which has the circle and text) for the data like shown in the function below.

functionfindNode(text){
  var DOM = d3.selectAll(".node")[0].find(function(node){
    return (d3.select(node).data()[0].name == text);
  })
  return DOM;
}

So now when ever you have the data and you want to find the group it associates to.

You can make use of the above function and call.

var k = findNode("physics");//this will return the DOM which has the node physics.

Hope this helps!

Post a Comment for "How Can I Change Style Class & Content Of Text For Ancestors In This D3.js Tree?"