score:1

Accepted answer

You don't have to destroy the graph - simply put your fill method call after merge.

.merge(data)
.attr("fill", function (d) {
      switch(d.group) {
         case "use case":
             return useCaseColor;
         case "data service":
             return dataServColor;
         case "source":
             return sourceColor;
      }
})

merge allows you to work with both initial & enter selections, so you can update it correctly.


Related Query