Skip to content

fix: BROS-128: Correct multi-channel rendering and dynamic scaling #7790

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

Conversation

cloudmark
Copy link
Contributor

@cloudmark cloudmark commented Jun 18, 2025

This PR addresses and fixes several critical bugs within the <TimeSeries> component, enabling the correct rendering and dynamic scaling of multi-channel charts, particularly with large datasets. The changes ensure that the component is robust, performant, and behaves as expected when handling complex time series visualizations.

This solves issue #7789.

Reason for change

The <TimeSeries> component was failing to render data correctly when using a <MultiChannel> configuration or the multiaxis="true" attribute. The primary symptoms were a blank main chart view despite the overview scrubber being populated, and a Y-axis that would not scale dynamically on zoom.

This was caused by three distinct bugs:

  1. Rendering Failure: A typo (this.line instead of channel.line) in TimeSeriesVisualizer.jsx prevented the SVG path for channels from ever being drawn.
  2. Dynamic Scaling Failure: The Y-axis scaling logic for large datasets was flawed, using a CSS transform that did not update correctly. The component now forces a proper redraw of the path to ensure the Y-axis scales with the visible data.
  3. Incorrect Component Invocation: The Channel.jsx component was not correctly activating the TimeSeriesVisualizer for multi-channel views, leading to multiple, conflicting chart instances being rendered. The logic is now corrected to render a single, unified visualizer.

Video

Before:
The main chart area is blank and does not render the channel data. The Y-axis is not scaled correctly.

https://www.loom.com/share/50fc240f1bae4d72ad421bdb9c2c8dfa

After:
All channels are rendered correctly in a single, unified chart. The Y-axis now scales dynamically and accurately as the user zooms and pans through the data.

https://www.loom.com/share/7d50d09befce4d19ad3da847ca2d6be7

Rollout strategy

These changes are bug fixes to core functionality and can be rolled out directly. There is no feature flag associated with this fix.

Testing

Verification was performed by:

  1. Creating a new project with the labeling configuration and task data specified in issue <TimeSeries> Doesn’t Render MultiChannel Data; Y-Axis Scaling Ignored on Zoom #7789.
  2. Observing the initial broken behavior (no channels rendered).
  3. Applying the code changes and confirming that all channels now render correctly.
  4. Zooming and panning on the timeline to verify that the Y-axis scales dynamically and smoothly as expected.

Risks

There are no known security or performance risks associated with this change. The fixes improve rendering performance and correctness for the targeted use case. The changes are scoped to the TimeSeries component and do not affect other parts of the application.

Reviewer notes

The core of the fix lies in three places:

  • The typo fix in TimeSeriesVisualizer.jsx's initializeChannel method.
  • The updated scaling logic in TimeSeriesVisualizer.jsx's setChannelRangeWithScaling method.
  • The corrected component rendering logic in Channel.jsx's HtxChannelViewD3 function, which now properly uses TimeSeriesVisualizer when multiaxis="true".

Please review these three areas to confirm the logic is sound and correctly addresses the issues outlined in the linked ticket.

@cloudmark cloudmark requested a review from a team as a code owner June 18, 2025 17:49
Copy link

netlify bot commented Jun 18, 2025

👷 Deploy request for label-studio-docs-new-theme pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8ed311b

Copy link

netlify bot commented Jun 18, 2025

👷 Deploy request for heartex-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8ed311b

Copy link

netlify bot commented Jun 18, 2025

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit 8ed311b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/68552b36ce2d6a000867a66d
😎 Deploy Preview https://deploy-preview-7790--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 Jun 18, 2025

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit 8ed311b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/68552b364b7edb0008385b32
😎 Deploy Preview https://deploy-preview-7790--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 Jun 18, 2025
@@ -910,7 +884,15 @@ class TimeSeriesVisualizerD3 extends React.Component {
}
}

this.renderBrushes(this.props.ranges, flushBrushes);
// Batch brush rendering to prevent visual artifacts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you expect multiple renders here? Or what is the problem here?

@cloudmark cloudmark force-pushed the fix/7789-multichannel-timeseries-fix branch 2 times, most recently from cb0cfac to c5e11b0 Compare June 20, 2025 08:08
- Remove complex optimization code (useOptimizedData, optimizedSeries, dual paths)
- Fix zoom to use updateTR() instead of throttledRangeUpdate() for immediate response
- Add MobX reactions for instant overview brush and channel visibility updates
- Simplify rendering to always use lineSlice with single path approach
- Fix initial waveform rendering by using channel.line instead of this.line
- Consolidate all reactive setup in componentDidMount for better organization

Resolves issues with delayed updates during zoom/pan operations and overview brush changes.
@cloudmark cloudmark force-pushed the fix/7789-multichannel-timeseries-fix branch from c5e11b0 to 8ed311b Compare June 20, 2025 09:34
@cloudmark
Copy link
Contributor Author

Hey Andrew (@hlomzik) I cleaned up and fixed all issues, here is the before and after

Before:
https://www.loom.com/share/50fc240f1bae4d72ad421bdb9c2c8dfa

New:
https://www.loom.com/share/7d50d09befce4d19ad3da847ca2d6be7

What was broken:

  • Delayed zoom/pan updates: TimeSeriesVisualizer wasn't updating immediately during zoom operations - lines would lag behind brushes
  • Overview brush disconnected: When dragging the overview brush (bottom area), the main visualization wouldn't update until manual refresh
  • Channel visibility delays: Clicking channel legend to show/hide lines had delayed response
  • Initial render issues: Waveforms wouldn't show properly on first load
  • Broken optimizations: Complex optimization code was causing rendering glitches and inconsistencies

What was fixed:

  • Immediate zoom response: Fixed zoom to use updateTR() for instant visual feedback
  • Reactive overview updates: Added MobX reactions so overview brush changes update main view immediately
  • Instant channel visibility: Channel legend clicks now immediately show/hide corresponding lines
  • Reliable initial rendering: Fixed waveform display on startup
  • Simplified architecture: Removed complex dual-path optimization system that was causing bugs
  • Consolidated reactive logic: All MobX reactions organized in one place for easier maintenance

The TimeSeriesVisualizer now responds immediately to all user interactions and provides smooth, reliable performance!

I would recommend that we review this rather soon because the change is currently on develop and anyone using the timeseries is suffering from this bug.


@makseq makseq changed the title fix: Correct multi-channel rendering and dynamic scaling fix: BROS-128: Correct multi-channel rendering and dynamic scaling Jun 20, 2025
@cloudmark
Copy link
Contributor Author

Closing @Gondragos did a better fix, which keeps all the optimisation.

@cloudmark cloudmark closed this Jun 20, 2025
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