Architecture & Engine Internals
Under the hood: RenderLoop, dirty-flag batching, transform matrices, headless state machines, and hardware decoupling.
QuaCharts was architected from day one as a zero-dependency, headless-first visual calculation engine. Instead of binding tightly to SVG elements or monolithic Canvas contexts, the runtime is split into four decoupled pillars: the Coordinate State Machine, the Reactive Data Layer, the Dirty-Flag RenderLoop, and the Multi-Target Hardware Driver.
Subsystem Breakdown
| Subsystem | Key Classes | Functionality | Threading Model |
|---|---|---|---|
| RenderLoop | RenderLoop, FrameScheduler | Coalesces redraw requests into single requestAnimationFrame ticks using 64-bit dirty bitmasks. | Main thread or OffscreenWorker |
| Transform Matrices | ViewportTransform, AffineMatrix2D | Projects data space (e.g. Unix millis × price) to viewport space (device pixels) in sub-microsecond vector operations. | Main CPU SIMD |
| Data Pipeline | SeriesStore, RingBuffer, LODManager | Zero-allocation ring buffers for tick streaming and LTTB downsampling for huge historical datasets. | SharedArrayBuffer ready |
| Event Dispatcher | EventBus, HitTester, InteractionManager | Spatial grid indexing (R-Tree / KD-Tree) for O(log N) crosshair snapping and multi-series tooltip queries. | Worker or Main UI thread |
| Calendar Engine | CalendarStateMachine, RFC5545Engine | Deterministic timezone arithmetic, recurring event expansion, and multi-resource timeline collision solvers. | Pure Headless TS |
Dirty-Flag Scheduling
When high-frequency price feeds stream 5,000 updates per second, naive charting libraries trigger 5,000 layout recalcs and canvas redraws, causing catastrophic frame drops. QuaCharts utilizes bitwise dirty flags:
Layer Isolation Pattern
Heavy data layers (bars, lines, candlesticks) render on separate canvas layers from interactive HUDs (crosshairs, value badges, selection boxes). When the cursor moves, only the lightweight HUD canvas re-renders, while millions of price points remain untouched in GPU VRAM.