Skip to content

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

Closed

Description

@bognikol

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 :-)

Activity

  1. mcnuttandrew commented on Oct 2, 2018

    @mcnuttandrew
    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.

  2. bognikol commented on Oct 31, 2018

    @bognikol
    ContributorAuthor

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

    Cheers

  3. bognikol commented on Nov 1, 2018

    @bognikol
    ContributorAuthor

    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 :-)

  4. mcnuttandrew commented on Nov 1, 2018

    @mcnuttandrew
    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.

  5. bognikol commented on Nov 13, 2018

    @bognikol
    ContributorAuthor

    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

  6. mcnuttandrew commented on Nov 13, 2018

    @mcnuttandrew
    Contributor

    Hey @bognikol

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

  7. bognikol commented on Nov 29, 2018

    @bognikol
    ContributorAuthor

    Pull request that contains fix: #1046

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions