Skip to content

[Bug] Crash in filterGraphicsByDatum when setHovered receives datums from multiple series (out-of-bounds access on collection marks) #4678

Description

@CrazyBucket

Version

2.1.6 (reproduced source-wise; originally found on 2.0.0)

Link to Minimal Reproduction

https://gist.github.com/CrazyBucket/0b6018dd186c1921ba85165c1bbf177b

Steps to Reproduce

  1. Open the reproduction link.
  2. The chart is rendered successfully.
  3. setHovered is called with a datum array that contains more items than the target mark's internal datum array.
  4. Observe the runtime error in the console:

Current Behavior

TypeError: Cannot read properties of undefined (reading 'time')
at index.min.js:15:1476662
at Array.every ()
at index.min.js:15:1476642
at Array.every ()
at index.min.js:15:1476626
at Array.filter ()
at index.min.js:15:1476588
at Array.forEach ()
at index.min.js:15:1476478
at Array.forEach ()

Expected Behavior

setHovered should handle unmatched datum gracefully.

Possible expected behaviors:

  • ignore datum that cannot be matched
  • return without throwing an exception

A user-facing runtime crash should not happen.

Environment

- **OS**: macOS, iOS
- **Browser**: Chromium 139.0.7258.128, Safari (iOS WebKit)
- **Framework**: React
- **VChart Version**: 2.0.0, 2.1.6

Any additional comments?

Background / How we hit this

We use a multi-series health trend chart (blood pressure: systolic & diastolic) and implement cross-series highlighting via setHovered.

When the user touches the chart, we pass one datum per series at the hovered x position:

vchart.setHovered([systolicDatum, diastolicDatum])

I would be happy to submit a PR to fix this issue if the maintainers agree with the proposed direction.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions