Skip to content

Conversation

yyassi-heartex
Copy link
Contributor

This pull request improves the accuracy and reliability of time selection in the time series editor by introducing a new utility function that snaps requested time values to the nearest actual data point. This helps avoid floating-point precision errors when users interact with time-based visualizations. The changes are applied consistently across all relevant user interactions and synchronization logic.

original PR: #8602

Key improvements:

Precision and Data Consistency Enhancements:

  • Added a new helper function snapToNearestDataPoint in TimeSeries/helpers.js that efficiently finds the closest time value in the dataset to a requested time, minimizing floating-point errors.
  • Updated all user interactions (cursor movement, brush clicks, and sync events) in TimeSeries.jsx to use snapToNearestDataPoint when determining the final time value, ensuring all time-based actions align with actual data points. [1] [2] [3]

Code Maintenance:

  • Imported the new snapToNearestDataPoint function into TimeSeries.jsx.

Minor Cleanups:

  • Minor formatting adjustments in D3 axis and line rendering code to maintain consistency. [1] [2]

cloudmark and others added 2 commits October 8, 2025 10:15
…recision 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
@yyassi-heartex yyassi-heartex requested a review from a team as a code owner October 10, 2025 18:29
Copy link

netlify bot commented Oct 10, 2025

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit a622089
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-docs-new-theme/deploys/68e9509430eb80000841990f

Copy link

netlify bot commented Oct 10, 2025

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit a622089
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/68e950944de473000844f2c3
😎 Deploy Preview https://deploy-preview-8629--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Oct 10, 2025

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit a622089
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/68e95094ae5f320008a3c686
😎 Deploy Preview https://deploy-preview-8629--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the fix label Oct 10, 2025
Copy link

netlify bot commented Oct 10, 2025

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit a622089
🔍 Latest deploy log https://app.netlify.com/projects/heartex-docs/deploys/68e95094e12d7900083f46ad

Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 5.26316% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.06%. Comparing base (37705ba) to head (a622089).
⚠️ Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
.../libs/editor/src/tags/object/TimeSeries/helpers.js 4.00% 24 Missing ⚠️
web/libs/editor/src/tags/object/TimeSeries.jsx 7.69% 12 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (37705ba) and HEAD (a622089). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (37705ba) HEAD (a622089)
pytests 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8629      +/-   ##
===========================================
- Coverage    67.13%   60.06%   -7.08%     
===========================================
  Files          786      548     -238     
  Lines        60310    38805   -21505     
  Branches     10254    10263       +9     
===========================================
- Hits         40492    23310   -17182     
+ Misses       19815    15492    -4323     
  Partials         3        3              
Flag Coverage Δ
lsf-e2e 54.31% <5.26%> (-0.04%) ⬇️
lsf-integration 50.84% <5.26%> (-0.10%) ⬇️
lsf-unit 8.59% <2.63%> (+<0.01%) ⬆️
pytests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants