The useStreamingViewport hook is similar to useStreamingData but includes automatic viewport (x-axis domain) management. It's ideal for charts that need to show a moving window of time-series data.
Used in components: Not used internally by Once UI components
This is a utility hook for building custom real-time data visualizations with dynamic viewport adjustment. Use it when you need charts where the x-axis automatically scrolls with incoming data, such as live monitoring dashboards.
- Smooth data interpolation
- Automatic viewport adjustment
- Sliding window with dynamic x-domain
- Pause/resume streaming
- Reset functionality
- RequestAnimationFrame-based updates
Create a streaming chart with auto-adjusting viewport:
Monitor live system metrics with moving viewport:
The key difference is the xDomain return value:
- useStreamingData: Returns only data
- useStreamingViewport: Returns data + xDomain for chart axis
Use useStreamingViewport when you need the chart viewport to move with the data.
- Uses requestAnimationFrame for smooth animations
- Automatically pauses when running is false
- Cleans up on unmount
- Efficient sliding window implementation
- Real-time dashboards: System monitoring, analytics
- Live data feeds: Stock prices, sensor data
- Performance monitoring: Server metrics, application stats
- IoT dashboards: Temperature, humidity, sensor readings
- useStreamingData - Similar but without viewport management