You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: snap TimeSeries seek events to nearest data point to eliminate precision errors
When clicking on a TimeSeries visualization, seek events were emitting
inaccurate time values due to floating-point precision errors in the
pixel-to-time conversion calculations.
For example, clicking on data point 1770.677344 would emit a seek event
with value 1770.6719467913167, which doesn't exist in the original dataset.
This caused synchronization issues with audio/video players and affected
annotation accuracy.
Changes:
- Added snapToNearestDataPoint() helper function in helpers.js using
efficient binary search (O(log n)) to find the closest actual data point
- Refactored emitSeekSync() to snap center time before emitting
- Refactored plotClickHandler() to snap clicked time before processing
- Refactored handleMainAreaClick() to snap clicked time before processing
Benefits:
- Seek events now emit exact data point values from the dataset
- Eliminates ~135 lines of duplicated code across 3 locations
- Maintains backward compatibility with no breaking changes
- Improves synchronization accuracy with video/audio players
- Ensures annotation precision in time-based labeling tasks
Bug demonstration: https://www.loom.com/share/5f1f429a21f0438ca5f11e7146570bfe
Fix demonstration: https://www.loom.com/share/b1b2b9ea3230461eb6e58848c40edfe2
Files changed:
- web/libs/editor/src/tags/object/TimeSeries/helpers.js
- web/libs/editor/src/tags/object/TimeSeries.jsx
Related To: #8601
0 commit comments