Accepted answer

You can get the brush's selected y axis extent using:

brush.on('brush', function(d){  
    k = brush.extent();

To get the data with in the selected brush area do:

k = brush.extent();
j = data.filter(function(d){
    return k[0] <= && k[1] >;
console.log(j)//this is the selected dataset

Working code here

Hope this helps!


For d3v4, you can use this way :

var selection = d3.event.selection;
var e =, x); // return [start,end] for axis

Related Query