module.exports = addSubnodes;

function addSubnodes(root, node) {
  var subnodesGroup = root.append("g").attr("class", "subnodes");
  subnodesGroup.selectAll("g")
    .data(node.subnodes)
    .enter().append("g")
      .attr("class", function(d) { return "subnode " + d.class; })
      .each(function(d, i) {
        // Create the circle and text nodes within the subnode group
        var circleDom = d3.select(this).append("circle")
          .attr("cx", i * 22)
          .attr("cy", "0")
          .attr("r", "10");
        var textDom = d3.select(this).append("text")
          .text(d.label)
          .attr("x", i * 22)
          .attr("y", "5");

        // Center the text within the circle
        var circleBox = circleDom.node().getBBox();
        var textBox = textDom.node().getBBox();
        textDom.attr("transform", "translate(" +
          -(textBox.width / 2) + "," +
          -((circleBox.height - textBox.height - 5) / 2) + ")");

        // If the tooltip is open, render it
        if (d.tooltip) {
          d3.select(this).append("rect")
            .attr("x", i * 22)
            .attr("y", "10")
            .attr("width", 100)
            .attr("height", 30);
        }
      });

  return subnodesGroup;
}




module.exports = addSubnodes;

function addSubnodes(root, node) {
  var subnodesGroup = root.append("g").attr("class", "subnodes");
  subnodesGroup.selectAll("g")
    .data(node.subnodes)
    .enter().append("g")
      .attr("class", function(d) { return "subnode " + d.class; })
      .each(function(d, i) {
        // Create the circle and text nodes within the subnode group
        var circleDom = d3.select(this).append("circle")
          .attr("cx", i * 22)
          .attr("cy", "0")
          .attr("r", "10");
        var textDom = d3.select(this).append("text")
          .text(d.label)
          .attr("x", i * 22)
          .attr("y", "5");

        // Center the text within the circle
        var circleBox = circleDom.node().getBBox();
        var textBox = textDom.node().getBBox();
        textDom.attr("transform", "translate(" +
          -(textBox.width / 2) + "," +
          -((circleBox.height - textBox.height - 5) / 2) + ")");
      });

  return subnodesGroup;
}




--- 
+++ 
@@ -23,6 +23,15 @@
         textDom.attr("transform", "translate(" +
           -(textBox.width / 2) + "," +
           -((circleBox.height - textBox.height - 5) / 2) + ")");
+
+        // If the tooltip is open, render it
+        if (d.tooltip) {
+          d3.select(this).append("rect")
+            .attr("x", i * 22)
+            .attr("y", "10")
+            .attr("width", 100)
+            .attr("height", 30);
+        }
       });
 
   return subnodesGroup;
Test for tooltip rendering 1
