Rendering Pipelines: Canvas 2D, WebGL 2 & Hybrid
Deep dive into rendering pipelines: when to select Canvas 2D vs WebGL 2, automatic threshold handoff, and layered hybrid rendering.
QuaCharts features a unified graphics backend that dynamically orchestrates three rendering modalities: pure Canvas 2D, hardware-accelerated WebGL 2, and the Hybrid Pipeline. The chart consumer does not need to learn GLSL shaders—the same options work seamlessly across all three engines.
Pipeline Comparison Matrix
| Pipeline Mode | Optimal Dataset Size | Strengths | Fallback Strategy |
|---|---|---|---|
| Canvas 2D | 1 to 50,000 points | Crisp subpixel antialiasing, rich text typography, native path clipping, low memory initialization | Default for basic charts |
| WebGL 2 | 50,000 to 5,000,000+ points | GPU instanced draw calls, vertex buffer streaming, zero CPU bottleneck, 60fps pan/zoom | Falls back to Canvas 2D if WebGL unsupported |
| Hybrid Layering | Any size with complex UI | WebGL 2 draws dense data series; Canvas 2D overlay draws high-DPI crisp axis ticks, legends, and crosshairs | Best of both worlds (Default in "auto") |
Configuring Renderer Mode
You can explicitly declare the renderer mode or configure the automatic threshold at which the chart switches from Canvas 2D to WebGL 2 hardware acceleration:
Retina & High-DPI Auto-Scaling
By default, QuaCharts queries window.devicePixelRatio and applies appropriate scaling to canvas buffer dimensions while keeping CSS style width and height locked. This eliminates blurry lines on 4K monitors and MacBook Retina displays without requiring custom application math.
OffscreenCanvas Worker Rendering
For extreme enterprise analytics, you can transfer canvas control to a Web Worker via htmlCanvas.transferControlToOffscreen(). QuaCharts will execute all GL draw passes and tick ingestion in the background thread, leaving the main UI thread at 120 FPS.