Frankly, no scaling occurs.
var brush = d3.svg.brush() .x(x) .on("brush", display);//this calls display function on brush event drag.
Internal display function.
minExtent = brush.extent()[0],
Based on the maximum and minimum filter brushes, the data:
visItems = items.filter(function(d) {return d.start < maxExtent && d.end > minExtent;});
Reset domain with max and min brush.
x1.domain([minExtent, maxExtent]);
Select all rectangles in the upper area that do not have data associated with the brush in the DOM. update it with new scale values
rects = itemRects.selectAll("rect") .data(visItems, function(d) { return d.id; }) .attr("x", function(d) {return x1(d.start);}) .attr("width", function(d) {return x1(d.end) - x1(d.start);});
create any new rectangles if data is present but the DOM is missing.
rects.enter().append("rect") .attr("class", function(d) {return "miniItem" + d.lane;}) .attr("x", function(d) {return x1(d.start);}) .attr("y", function(d) {return y1(d.lane) + 10;}) .attr("width", function(d) {return x1(d.end) - x1(d.start);}) .attr("height", function(d) {return .8 * y1(1);});
Delete the entire rectangle outside the brush area or not in the list of filtered elements visItems
rects.exit().remove();
Similarly for the labels as for the rectangles above.
Hope this clears all your doubts.