The extent value has changed from v3 to v4.
extent in v3 meant an area with a matte finish, i.e. a range of choice within the general area bounded by the brush.
extent in v4 now refers to the total area bounded by the brush, and selection is the selected area, which was previously called extent . (Note that the selection can be obtained using d3.brushSelection , but is most often used as d3.event.selection in the brush event handler.
Also, in d3.v4, scales are no longer directly related to brushes; instead, the brush only works on the pixel area. Scales should be applied along the path (for brush settings) and along the path (to values ββreturned by brush event handlers). So, what was earlier, in d3.v3:
let brush = d3.brush() .brushY(brushScale) .extent([0, 10]);
in d3.v4 becomes something like:
let brush = d3.brushY() .extent([[0, brushScale.range()[0]], [sliderWidth, brushScale.range()[1]]]); let brushSel = svg.append('g').call(brush); brush.move(brushSel, [sliderScale(0), sliderScale(10)]);
Note that instead of setting the extent (v3), we move() (v4) the selection to a range of scaled pixels.
source share