Core conceptsInteractionInteractivity· 4 min read
Interactivity, Crosshairs & Tooltips
Crosshair snapping, shared hover tooltips, box zoom, pinch-to-zoom on mobile, and magnetic point inspection.
Interactive exploration is critical in high-density time-series data. QuaCharts incorporates an optimized hit-testing engine that provides fluid 60 FPS crosshair tracking, magnetic point snapping, shared multi-series tooltips, and seamless touch gestures on mobile devices.
Crosshair Modes & Snapping
Crosshairs can be constrained horizontally, vertically, or both, with automatic magnetic snapping to nearest data points:
crosshair-config.ts
1
const chart = createLineChart('#chart', {
2
crosshair: {
3
enabled: true,
4
mode: 'both', // 'x' | 'y' | 'both'
5
snapToData: true,
6
color: 'rgba(255, 255, 255, 0.4)',
7
dashStyle: 'dash', // 'solid' | 'dash' | 'dot'
8
label: {
9
enabled: true,
10
backgroundColor: '#0284c7',
11
format: '{value:.2f}',
12
},
13
},
14
});
Shared Multi-Series Tooltips
When analyzing multiple correlated instruments, shared tooltips aggregate all active series points under the current cursor index:
tooltip-config.ts
1
const chart = createChart('#chart', {
2
tooltip: {
3
enabled: true,
4
shared: true,
5
backgroundColor: 'rgba(15, 23, 42, 0.92)',
6
borderColor: 'rgba(255, 255, 255, 0.12)',
7
borderRadius: 8,
8
padding: 12,
9
formatter: function (points) {
10
const date = new Date(points[0].x).toLocaleDateString();
11
let html = `<div class="font-bold text-xs mb-1 text-slate-400">${date}</div>`;
12
for (const p of points) {
13
html += `
14
<div class="flex items-center justify-between gap-4 text-xs py-0.5">
15
<span style="color: ${p.color}">${p.seriesName}:</span>
16
<span class="font-mono font-semibold">$${p.y.toFixed(2)}</span>
17
</div>`;
18
}
19
return html;
20
},
21
},
22
});
Zoom & Pan Navigation
- Mouse Wheel Zoom: Pinch or scroll wheel zooms centered directly at cursor coordinate.
- Box Drag Selection: Click and drag to draw a bounding rectangle to zoom into a micro time window.
- Touch Gestures: Native multi-touch two-finger pinch-to-zoom and one-finger swipe panning.
- Reset Zoom: Double-click plot area or call chart.resetZoom() programmatically.