score:6

Accepted answer

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

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

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

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

Working code here

Hope this helps!

score:-1

For d3v4, you can use this way :

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


Related Query