Overview
Exchange Web uses TradingView’slightweight-charts library for displaying real-time candlestick charts. The ChartManager class provides a clean abstraction for chart initialization and updates.
ChartManager Class
TheChartManager class handles chart lifecycle and real-time updates:
chart_manager.ts
Configuration
- Chart Options
- Candlestick Colors
- Grid & Scales
Core Settings
| Option | Value | Description |
|---|---|---|
autoSize | true | Auto-resize to container |
crosshair.mode | Normal | Enable crosshair |
background | #121212 | Dark background |
textColor | white | White text for contrast |
Usage in TradeView
TheTradeView component integrates the chart with data fetching:
TradeView.tsx
Data Flow
Kline Data Fetching
Kline Data Fetching
- Fetch: Request kline data for the last 7 days
- Transform: Convert string values to numbers
- Sort: Ensure chronological order
- Initialize: Create chart with cleaned data
- Update: Apply real-time updates via
update()method
Real-Time Updates
The
update() method supports incremental candle updates. When newCandleInitiated is true, a new candle begins.Timeframe Options
Supported intervals:1m
1-minute candles for short-term trading
1H
1-hour candles for intraday analysis
1D
Daily candles for swing trading
1W
Weekly candles for long-term trends
KLine Data Structure
Memory Management
Performance Tips
Crosshair Customization
Common Issues
Chart not rendering
Chart not rendering
- Ensure container div has defined width and height
- Check that data is properly formatted with UTC timestamps
- Verify lightweight-charts is properly installed
Chart not updating
Chart not updating
- Confirm
update()is being called with correct data structure - Check that timestamps are in correct format (UTC seconds)
- Ensure chart instance hasn’t been destroyed
Related Components
- Trading Interface - Main layout integration
- Order Book - Complementary depth visualization