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

fix(tooltip): handle multiple points (#979) #1734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jernestmyers
Copy link

🐛 Bug Fix

Relates to #979

Adds an optional prop (findNearestDatumOverride) to the XYChart and GlyphSeries components that get passed into the useEventHandlers hook for improved tooltip behavior. This felt like a viable path given that the useEventHandlers hook already includes the following prop definition:

  /** Optionally override the findNearestDatum logic. */
  findNearestDatum?: (
    params: NearestDatumArgs<XScale, YScale, Datum>,
  ) => NearestDatumReturnType<Datum>;

I tested this approach in a new viz component we are building and the tooltip behaves as desired/expected by using findNearestDatumXY as the override function when consuming XYChart and GlyphSeries.

Happy to improve upon this implementation or open to alternatives.

* add optional prop used to override findNearestDatum logic in the useEventHandlers hook

Allows consumers to pass in custom logic or visx's findNearestDatumXY for more accurate
tooltip behavior
@owenbirdsall
Copy link

This looks good to me, it would be really helpful if this could be merged in as I imagine it's quite common to want to have multiple points occupying the same x location with varying y locations.

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

Successfully merging this pull request may close these issues.

3 participants