Skip to content

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