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

OnBrushDomainChangeEnd provides wrong domain #1400

Closed
sup-bs opened this issue Sep 19, 2019 · 4 comments · Fixed by #1422
Closed

OnBrushDomainChangeEnd provides wrong domain #1400

sup-bs opened this issue Sep 19, 2019 · 4 comments · Fixed by #1422

Comments

@sup-bs
Copy link

sup-bs commented Sep 19, 2019

Bugs and Questions

Checklist

  • [x ] This is not a victory-native specific issue. (Issues that only appear in victory-native should be opened here)

  • [x ] I have read through the FAQ and Guides before asking a question

  • [x ] I am using the latest version of Victory

  • [x ] I've searched open issues to make sure I'm not opening a duplicate issue

The Problem

onBrushDomainChangeEnd of VictoryBrushContainer provides the wrong domain: According to the Documentation, the current domain should be given. Instead, the domain of the whole Chart is provided.
In contrast, onBrushDomainChange works as expected.

Reproduction

See the following sandbox:
https://codesandbox.io/s/basic-victory-example-zrijg?fontsize=14

Drag the domain; the domains for onBrushDomainChangeEnd and onBrushDomainChange are printed in the console.

@jorko95
Copy link

jorko95 commented Oct 4, 2019

I have the same problem, onBrushDomainChangeEnd provied the hole chart domain, and not the selected domain.

@dippindots
Copy link

Same here, any solution?

@jorko95
Copy link

jorko95 commented Oct 18, 2019

I found a partial solution, I made this on my code:
I create two separate functions, the first to stock the value of the domain in a global variable, and the second to set the new domain to the state, using setState.

handleBrush called on onDomainChange
handleBrush(domain) {
this.nDomain = { x: [domain.x[0], domain.x[1]] };
}

onMouseUp called on onDomainChangeEnd
onMouseUp() {
this.setState({
selectedDomain: this.nDomain,
});
}

onBrushDomainChange={domain => this.props.handleBrush(domain)}
onBrushDomainChangeEnd={domain => this.props.onMouseUp()}

It works for me.

@dippindots
Copy link

@jorko95 Thanks for sharing your solution! I also have a workaround for my case, which is using debounce function from lodash:
onBrushDomainChange={_.debounce(this.onSelection, 500)}.

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