2.0 alpha
These docs describe 2.0. Install it with @once-ui-system/core@alpha.
On 1.8.x? Read the 1.x docs
TrademarkTrademarkDocs
Ctrl k
Search docs...
Hooks

useStreamingViewport

Updated: February 22, 2026
View on GitHub
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
  • 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:
Prop
Type
Default
initialData
T[]
windowSize
number
intervalMs
number
stepMs
number16
xKey
keyof T
numericKeys
Array<keyof T>
getNextTarget
({ lastPoint, nextX }) => Partial<T>
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
Edit this page on GitHub
TrademarkTrademark
Built with curiosity by Lorant One and the Design Engineers Club