You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Helper Function to Get X Coordinate from Mouse or Touch Event
function getXCoordinate(event) {
if (event.clientX !== undefined) {
return event.clientX; // Mouse event
} else if (event.touches && event.touches.length > 0) {
return event.touches[0].clientX; // Touch event
}
return null;
}
const chartElement = document.getElementById('chart');
function syncCrosshair(event){
const bcr = chartElement.getBoundingClientRect();
const x = bcr.left + getXCoordinate(event);
const y = bcr.top + getYCoordinate(event);
const btcDominanceY = btcDominanceSeries.coordinateToPrice(y);
const altcoinDominanceY = altcoinDominanceSeries.coordinateToPrice(y);
const time = chart.timeScale().coordinateToTime(x);
console.log(formatDateTime(time * 1000))
if (!Number.isFinite(altcoinDominanceY) || !Number.isFinite(btcDominanceY) || !Number.isFinite(time)) {
return;
}
chart.setCrosshairPosition(btcDominanceY, time, btcDominanceSeries);
chart.setCrosshairPosition(altcoinDominanceY, time, altcoinDominanceSeries);
}
Actual behavior:
The time variable returned is incorrect. There is always a fixed horizontal gap between my cursor position and the crosshair (the setCrosshairPosition call is correct, but the time returned is incorrect as I verified from console.log).
The gap length changes when the screen size changes.
Expected behavior:
The time variable should return the time under my cursor.
Screenshots:
The text was updated successfully, but these errors were encountered:
Lightweight Charts™ Version: 5.0.2
Steps/code to reproduce:
I followed the Set Crosshair Position tutorial (Tracking without long-press on mobile) to synchronize the crosshair with the cursor position on click.
https://tradingview.github.io/lightweight-charts/tutorials/how_to/set-crosshair-position
Actual behavior:
The time variable returned is incorrect. There is always a fixed horizontal gap between my cursor position and the crosshair (the setCrosshairPosition call is correct, but the time returned is incorrect as I verified from console.log).
The gap length changes when the screen size changes.
Expected behavior:
The time variable should return the time under my cursor.
Screenshots:
The text was updated successfully, but these errors were encountered: