Hi excuse the newbie nature of this question (and code snippet).
I want to set the extent of a brush. I firstly, I better make sure that my definition of "extent" is correct.
It seems that in most brush examples (such as this: http://bl.ocks.org/mbostock/6232620 ) when the user is initially presented with the brush -- a region is not selected.
I would like to set an initial region...so that the user can already see a selection.
I figure that this selected region is called the "extent".
I have defined my brush as follows:
var the_brush = d3.brushX().extent([[0, 0], [width, height]]).handleSize(50).on("brush", brushed);
And then attach it to an svg element using the following:
svg.append("g").attr("class", "brush").call(the_brush);
The height and width are initially defined as 50 and 880 respectively.
I then figure that I should be able to experiment in Chrome console to redefine the extent such that a shaded area is displayed.
I use this command (in the Chrome console):
the_brush.extent([200, 0], [500, 50])
But a function is returned.
Mmmm I am obviously missing something quite fundamentially here...by what..?
I hope it is clear from my question...my actual objective. That is when the user first opens the page that (s)he is presented with a brush widget that already has a portion selected.
There is a hacky (but working) copy of the code here
My question is similar to a previous question here
But I do not think that the previous solution is applicaton to D3 version 4.
Thanks.