The included fiddle shows that when zoomed in, the blue rectangles scale as expected, but the yellow rectangles do not! The main difference is that the yellow rectangles were added to the 'g' element with the included text. Any ideas why?
https://jsfiddle.net/sjp700/u6rj20jc/1/
var group = svg.selectAll(".rectangle")
.data(data);
gEnter = group.enter()
.append("g")
.attr("class", "rectangle")
.attr("fill", "yellow")
.attr("transform", function (d) { return "translate(" + x(d.start) + "," + y(d.finish) + ")"; });
gEnter.append("rect")
.attr("class", "rectband")
.merge(gEnter)
.attr("width", 50)
.attr("height", 18)
.style("opacity", .5)
.style("stroke", "black");
source
share