diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 4699f6add..8d6679251 100644 Binary files a/.vs/AAWebPlatform/v15/.suo and b/.vs/AAWebPlatform/v15/.suo differ diff --git a/ChartUtilities.js b/ChartUtilities.js index 558d0fc99..3f0b9ce02 100644 --- a/ChartUtilities.js +++ b/ChartUtilities.js @@ -148,98 +148,3 @@ function recalculatePeriod(zoomLevel) { return ONE_DAY_IN_MILISECONDS; } } - - -function checkIfMoreTradesAreNeeded(trades, container, timeLineCoordinateSystem, marketTrades, callBackFunction) { - - /* - - To know when to load more trades, we will see were the first candle is in relation to the viewport. - - If we are too close to the visible area, we will request more trades, so as to have more candles ready. - If we are to far, we will request a new set of trades with fewer than the ones we have, so as to have les candles. - - */ - - let firstTrade = trades[0]; - let lastTrade = trades[trades.length - 1]; - - let firstTradePoint = { - x: firstTrade.datetime.valueOf(), - y: 0 - }; - - let lastTradePoint = { - x: lastTrade.datetime.valueOf(), - y: 0 - }; - - firstTradePoint = timeLineCoordinateSystem.inverseTransform(firstTradePoint, container.frame.height); - firstTradePoint = transformThisPoint(firstTradePoint, container); - - lastTradePoint = timeLineCoordinateSystem.inverseTransform(lastTradePoint, container.frame.height); - lastTradePoint = transformThisPoint(lastTradePoint, container); - - let totalDistance = lastTradePoint.x - firstTradePoint.x; // Is the screen distance between the first and last trade. - let tradesDistance = lastTrade.id - firstTrade.id; // It is the distance in Id between the first and last trade. - let viewPortWidth = viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x; - - /* - - Knowing the distance in the screen and the distance in Ids from the first and last trade, can leads us to know the distance in ids, from - where the first trade is, to where it should be. - - To do that we will first calculate how many trades are currently fitting in the viewport. - - */ - - let viewPortTrades = Math.round(viewPortWidth * tradesDistance / totalDistance); - - let estimatedFisrtTradeId = firstTrade.id; - let estimatedLastTradeId = lastTrade.id; - - let needToRequestMoreTrades = false; - - if (firstTradePoint.x > viewPort.visibleArea.bottomLeft.x - viewPortWidth) { - - /* We need more trades before the first one. The first trade should be less than 2 times the view port width. Lets estimate an Id for a trade just there. */ - - estimatedFisrtTradeId = firstTrade.id - viewPortTrades; - - needToRequestMoreTrades = true; - } - - if (firstTradePoint.x < viewPort.visibleArea.bottomLeft.x - viewPortWidth * 2) { - - /* We need more get rid of some trades after the first one. */ - - estimatedFisrtTradeId = firstTrade.id + viewPortTrades; - - needToRequestMoreTrades = true; - } - - if (lastTradePoint.x < viewPort.visibleArea.bottomRight.x + viewPortWidth) { - - /* We need more trades after the last one. */ - - estimatedLastTradeId = lastTrade.id + viewPortTrades; - - needToRequestMoreTrades = true; - } - - if (lastTradePoint.x > viewPort.visibleArea.bottomRight.x + viewPortWidth * 2) { - - /* We need more get rid of some trades before the last one. */ - - estimatedLastTradeId = lastTrade.id - viewPortTrades; - - needToRequestMoreTrades = true; - } - - if (needToRequestMoreTrades === true) { - - marketTrades.getTradesById(estimatedFisrtTradeId, estimatedLastTradeId, callBackFunction); - - } - -} \ No newline at end of file