Replay
The Replay feature provides comprehensive chart replay capabilities for the financial charting library. This system enables users to replay historical market data at various speeds, supporting both manual and automatic playback modes.
Key Features
- Manual step-by-step replay (forward/backward)
- Automatic playback with adjustable speed
- Speed control (1x, 2x, 5x, 10x)
- Start/stop/pause controls
- Timestamp-based synchronization
- Real-time data switching
- Performance-optimized replay rendering
Architecture / Behavior
The replay system follows a layered architecture:
- UI Layer: Replay panel with playback controls
- API Layer: ChartApi and GlobalApi replay methods
- State Layer: ChartStore manages replay state
- Engine Layer: ReplayManager handles timing and frame management
The replay flow: UI → ChartApi → ChartStore → ReplayManager → DataFeed → Canvas → UI.
API Usage
Initialization
The replay feature is enabled by default in the chart configuration:
const chart = Chart.create(document.getElementById('container'), {
// ... other options
enabled_features: ['replay'], // Enable replay functionality
});
Methods
ChartApi.startReplay() - Start replay from specified index:
// Start replay from bar index 100
chart.getApi().startReplay(100);
// Start replay from current position
chart.getApi().startReplay(chart.getApi().getVisibleRange().from);
ChartApi.stopReplay() - Stop replay and return to live mode:
chart.getApi().stopReplay();
ChartApi.playReplay() - Start automatic playback:
chart.getApi().playReplay();
ChartApi.pauseReplay() - Pause automatic playback:
chart.getApi().pauseReplay();
ChartApi.setReplaySpeed() - Set replay speed:
// Set speed to 5x
chart.getApi().setReplaySpeed(5);
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled_features | string[] | ['replay'] | Enable/disable replay functionality |
replay_default_speed | number | 1 | Default replay speed |
replay_max_speed | number | 10 | Maximum allowed replay speed |
replay_buffer_size | number | 1000 | Number of bars to buffer for replay |
Events
replay:start- Fired when replay startsreplay:stop- Fired when replay stopsreplay:play- Fired when automatic playback startsreplay:pause- Fired when automatic playback pauses
Customization
- UI styling can be customized via CSS classes
- Replay controls can be customized through configuration
- Playback speed options can be customized
- Replay panel visibility can be customized
Use Cases
- Backtesting trading strategies
- Analyzing historical price patterns
- Training and education
- Market analysis and research
- Integration with algorithmic trading systems
Limitations
- Requires sufficient historical data
- Performance depends on data feed response times
- Limited to data supported by connected data feeds
- Some data feeds may have limitations on historical data availability
✅ Supported
- Replay API methods exist and are functional
- Manual step-by-step replay
- Automatic playback
- Speed control
- Timestamp-based synchronization
❌ Not Supported
- Multi-symbol replay
- Cross-chart replay synchronization
- Advanced replay analytics
⚠️ Partial / External
- Backend API integration requires custom data feed implementation
- Replay buffer management requires custom implementation
Feature Classification
Core Feature - Fundamental functionality required for advanced chart analysis
Dependencies
- Requires backend? Yes (data feed API)
- Requires storage? No
- Requires real-time data? No (uses historical data)
- Requires UI controls? Yes (replay panel)
Missing Implementation Analysis
The replay functionality is fully implemented and production-ready. All core replay capabilities are present in the codebase with proper error handling and performance optimizations.
Consistency Validation
The replay API follows the same pattern as other API methods with consistent promise-based return values and error handling. Naming conventions are consistent with other features.
UI vs API Separation
- UI handles: Playback controls, speed selector, visual feedback
- API exposes:
startReplay(),stopReplay(),playReplay(),pauseReplay(),setReplaySpeed()methods - Must implement manually: Custom data feed replay support
User Flow
- User selects replay mode
- ChartApi initializes replay state
- ChartStore sets replay mode
- ReplayManager starts timing loop
- DataFeed provides historical bars
- Chart renders each bar sequentially
- UI updates playback controls
Integration with Existing Docs
This feature should be linked from:
- Charting section → Replay Panel
- API Reference → ChartApi
- Getting Started → Quick Start Guide
- Advanced Features → Historical Analysis