When there is no candle it still positions browser

This commit is contained in:
Luis Fernando Molina committed 2018-05-31 18:40:27 +02:00
1 parent c96cb3cf6c
commit 37a9285873
1 file changed
+32
+32
View File
@@ -198,10 +198,17 @@
/* Now we calculate which candle has this new time, because it will give us the y coordinate. */
let candleFound = false;
let lastClose;
for (let i = 0; i < candles.length; i++) {
lastClose = candles[i].close;
if (value >= candles[i].begin && value <= candles[i].end) {
candleFound = true;
let targetPoint = {
x: value,
y: candles[i].open
@@ -253,6 +260,31 @@
}
}
if (candleFound === false) {
let targetPoint = {
x: value,
y: lastClose
};
targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint);
targetPoint = transformThisPoint(targetPoint, thisObject.container);
let center = {
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2,
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2
};
let displaceVector = {
x: center.x - targetPoint.x,
y: center.y - targetPoint.y
};
viewPort.displace(displaceVector);
return;
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] positionAtDatetime -> err.message = " + err.message); }