score:1

Accepted answer

brush.extent() without argument now returns the function that calculates the extent, not the brush’s position. Use d3.event.selection instead.

Once you have the selected extent, compare it to your x scale:

brush.on('end', function(){
    var k = d3.event.selection; // extent of the brush, [x0, x1] since it's an x-brush

    var j = data.filter(function(d) {
        var x0 = x(d.ID), //  start of the corresponding band 
            x1 = x0 + x.bandwidth(); // end of the corresponding band 

        // check if the start of the brush is before the band 
        // and if the end of the brush is after the end of the band
        return k[0] <= x0 && k[1] >= x1;
    });

    console.log(j);
});

Related Query