The useStreamingData hook creates smooth, animated data streams for real-time visualizations. It interpolates between data points and maintains a sliding window of values, perfect for live charts and dashboards.
Used in components: Not used internally by Once UI components
This is a utility hook for building custom real-time data visualizations. Use it when you need to create live charts, dashboards, or streaming data displays with smooth animations.
- Smooth interpolation between data points
- Configurable sliding window size
- Customizable update intervals
- Pause/resume streaming
- Reset to initial state
- RequestAnimationFrame-based updates
Create a streaming line chart:
Stream multiple data series:
- Initialization: Starts with initialData trimmed to windowSize
- New point creation: Every intervalMs, creates a new data point
- Interpolation: Smoothly animates from current to target values
- Sliding window: Maintains only the last windowSize points
- Animation: Updates every stepMs using requestAnimationFrame
- Use stepMs: 16 for 60fps (smooth)
- Use stepMs: 33 for 30fps (more efficient)
- Keep windowSize reasonable (20-50 points)
- Avoid expensive calculations in getNextTarget
System monitoring dashboard:
- useStreamingViewport - Similar but with dynamic viewport adjustment