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

Error: "xScale.invert is not a function" when handling Highlight component onBrush / onBrushEnded events #987

Closed
bognikol opened this issue Oct 2, 2018 · 7 comments

Comments

@bognikol
Copy link
Contributor

bognikol commented Oct 2, 2018

Not sure if this is a defect, but I get following error when trying to handle onBrush / onBrushEnded events on Highlight component:

image

while using Highlight component like this:

image

Any ideas?
Thanks in advance :-)

@mcnuttandrew
Copy link
Contributor

Hey @bognikol

Unfortunately the Highlight component does not current support brushing across ordinal or categorical axes. This is because we rely on d3-scale which does not support inverses for those sorts of scales. I would be happy to accept a PR adjusting them here, or, maybe more engineeringly applaud a PR to d3-scale adding that functionality (though I kinda assume there is a reason it is not supported?).

You can sort of get around this in the same way that we do in the parallel coordinates chart.

@bognikol
Copy link
Contributor Author

I created new pull request to d3-scale where I added band.inverse(). Hopefully it will be merged soon.
d3/d3-scale#151

Cheers

@bognikol
Copy link
Contributor Author

bognikol commented Nov 1, 2018

Hi @mcnuttandrew,

I need d3/d3-scale#151 to be merged rather quickly. What is your previous experience, is anyone going to look at it any time soon? What is the status of d3-scale repo in general? Is it better approach to make a workaround is react-vis?

Thanks :-)

@mcnuttandrew
Copy link
Contributor

Hey @bognikol

In my experience d3 can sometimes be slow moving. That said looking at the other PRs open on that repo, there is exactly a PR covering this problem that hasn't been merged in two years.

So this looks bad but there is a light. Specifically, it appears vega-scale (https://github.com/vega/vega-scale) supports exactly this usage. I would support a PR that brings in vega-scale just for your use case, but with a follow up issue to stop using d3-scale and use vega-scale instead.

Sorry I pointed you in the wrong direction about PRing d3-scale initially, mea culpa.

@bognikol
Copy link
Contributor Author

Hi @mcnuttandrew,

No problem for wrong directions :-)

As I was tight in time, I had to fork react-vis and to implement a workaround directly.
Is it viable to merge this workaround to uber/react-vis as a temporary solution?
bognikol@353b98a

Cheers,
Bogdan

@mcnuttandrew
Copy link
Contributor

Hey @bognikol

Write some tests and throw that branch through our linter and I think it'll be good to go!

@bognikol
Copy link
Contributor Author

bognikol commented Nov 29, 2018

Pull request that contains fix: #1046

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

No branches or pull requests

2 participants