setCrosshairPosition method
Updates crosshair position and extracts hovered candle under pointer.
Implementation
void setCrosshairPosition(Offset? position) {
if (!_showCrosshair) {
_crosshairPosition = null;
return;
}
_crosshairPosition = position;
if (position != null && candles.isNotEmpty) {
final converter = CoordinateConverter(
viewport: _viewport,
totalCandles: candles.length,
);
final index = converter.xToIndex(position.dx);
if (index >= 0 && index < candles.length) {
_hoveredCandle = candles[index];
}
} else {
_hoveredCandle = null;
}
notifyListeners();
}