Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brush.extent does not appear to resize the invisible overlay #43

Closed
SylvainCorlay opened this issue Feb 28, 2019 · 4 comments
Closed

brush.extent does not appear to resize the invisible overlay #43

SylvainCorlay opened this issue Feb 28, 2019 · 4 comments

Comments

@SylvainCorlay
Copy link

We expect (maybe wrongly) that a call to brush.extent would resize the invisible overlay capturing mouse events but it does not appear to be the case.

Our usecase for making such a call is to adjust the overlay when the figure is resized. We also move the brush to correspond to the previously selected values.

@SylvainCorlay
Copy link
Author

SylvainCorlay commented Feb 28, 2019

screenshot from 2019-02-28 17-39-02

viewof selection = {
  // SVG width is set to 500 originaly
  const svg = d3.select(Object.assign(DOM.svg(500, 100), {value: null}))
                .style("border", "solid 1px black");
  const brush = d3.brushX();
  const g = svg.append("g").call(brush);
  svg.select(".overlay").style("fill", "yellow");
  // Changing width of svg to 800
  svg.attr("width", 800);
  // Update extent of brush to new size
  brush.extent([[0, 0], [800, 100]]);
  // Move brush beyond previous extent
  brush.move(g, [500, 600]);
  yield svg.node();
}

// Now try dragging the selection

@mbostock
Copy link
Member

You need to re-render the brush after you reconfigure it using selection.call(brush). The brush object doesn’t retain any reference to the selection you bind it to, so the only way to change the displayed state of the brush is to re-render it with brush or brush.move.

@SylvainCorlay
Copy link
Author

You need to re-render the brush after you reconfigure it using selection.call(brush). The brush object doesn’t retain any reference to the selection you bind it to, so the only way to change the displayed state of the brush is to re-render it with brush or brush.move.

Thanks. This is what we ended up doing. We though it was unintended behavior.

@jwasilgeo
Copy link

Thanks, this brush re-rendering suggestion helped me out too in a similar situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants