Search code examples
javascriptd3.jshighlightsunburst-diagram

Select segments of the same name in d3.js sunburst


I'm trying to adjust this example http://bl.ocks.org/kerryrodden/7090426:

enter image description here

so that the hover over selects all segments of the same name instead of the ancestors of the current segment.

This is the script

  vis.selectAll("path")
      .filter(function(node) {
                return (sequenceArray.indexOf(node) >= 0);
              })
      .style("opacity", 1);
}

Thank you kindly for your assistance


Solution

  • The code that you mentioned in the question should be replaced with the following code:

      var currentName = d.name;
      vis.selectAll("path")
          .filter(function(node) {
                    return (node.name == currentName);
                  })
          .style("opacity", 1);
    }
    

    The effect is shown here: (demo jsfiddle is also available; this is somewhat scaled down version of the original example that I used for debugging; also, this jsfiddle is the version with original highlighting, if you can make use of it)

    enter image description here