rvberloo
rvberloo

Reputation: 11

d3.js v4 how to set brush programmatically

I am building a version of this parallel coordinate view in d3.js v4. https://bl.ocks.org/syntagmatic/05a5b0897a48890133beb59c815bd953

In my example I have a predefined selection (in the form of a [min,max] array that I would like to set programatically as a brush in one or more of the axes, after the plot has loaded. But I cannot seem to find a way to do it. Most examples I found on setting a brush from code are using d3 v3 and use setting extent but that does not work anymore in v4 it seems.

can someone give me some tips and a simple example hot to do this in this case (so with multiple axes and brushes active) ?

thanks

Upvotes: 1

Views: 3347

Answers (1)

pmkro
pmkro

Reputation: 2550

Select your brush group and call brush.move, then also pass an array with the start and end coordinates. Your brush move event will then take care of the rest.

d3.select(".brush").call(brush.move, [[startX, endX], [startY, endY]]);

Upvotes: 3

Related Questions