From bc9c3d15fa4054753df35e8738bc710dad1cdf71 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 10 Oct 2020 12:36:54 +0200 Subject: [PATCH] Charting Details Fixed --- Candles.js | 40 ++++++++++++++++++++-------------------- Volumes.js | 7 +++---- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Candles.js b/Candles.js index 0f9eea85d..9fd121278 100644 --- a/Candles.js +++ b/Candles.js @@ -445,9 +445,8 @@ if ( (candle.begin >= leftDate.valueOf() && candle.end <= rightDate.valueOf()) && - (candle.begin >= coordinateSystem.min.x && candle.end <= coordinateSystem.max.x) - ) - { + (candle.begin >= coordinateSystem.min.x && candle.end <= coordinateSystem.max.x) + ) { candles.push(candle); @@ -479,6 +478,10 @@ if (candles.length > 0) { + /* On screen candles */ + let onScreenCandles = [] + let mouseCandle + /* Now we calculate all the points. */ for (let i = 0; i < candles.length; i++) { @@ -514,6 +517,15 @@ candle.candlePoint3 = transformThisPoint(candle.candlePoint3, thisObject.container); candle.candlePoint4 = transformThisPoint(candle.candlePoint4, thisObject.container); + /* Skip the first candle with zero at open */ + if (candle.open === 0) { continue } + + if (candle.candlePoint2.x < canvas.chartingSpace.viewport.visibleArea.bottomLeft.x || candle.candlePoint1.x > canvas.chartingSpace.viewport.visibleArea.bottomRight.x) { + continue + } + + addToOnScreenCandles(candle) + candle.stickPoint1 = { x: candle.begin + timeFrame / 7 * 3.2, y: candle.max @@ -591,23 +603,11 @@ candle.stickPoint2 = thisObject.fitFunction(candle.stickPoint2); candle.stickPoint3 = thisObject.fitFunction(candle.stickPoint3); candle.stickPoint4 = thisObject.fitFunction(candle.stickPoint4); - } - /* On screen candles */ - let onScreenCandles = [] - let mouseCandle - for (let i = 0; i < candles.length; i++) { - - candle = candles[i]; - /* Skip the first candle with zero at open */ - if (candle.open === 0) { continue } - - if (candle.candlePoint2.x < canvas.chartingSpace.viewport.visibleArea.bottomLeft.x || candle.candlePoint1.x > canvas.chartingSpace.viewport.visibleArea.bottomRight.x) { - continue - } + function addToOnScreenCandles(candle) { /* Contributing to Auto-Scale*/ coordinateSystem.reportYValue(candle.max) @@ -615,7 +615,7 @@ //if (onScreenCandles.length < 15000) { - onScreenCandles.push(candle) + onScreenCandles.push(candle) //} if (userPositionDate >= candle.begin && userPositionDate <= candle.end) { @@ -641,7 +641,7 @@ if (lowResolution === false) { browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK + ', 1)'; browserCanvasContext.fill(); - + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.LIGHT + ', 1)'; browserCanvasContext.lineWidth = 1; browserCanvasContext.setLineDash([0, 0]) @@ -697,7 +697,7 @@ elementsPlotted++ } - + browserCanvasContext.closePath(); if (lowResolution === false) { @@ -716,7 +716,7 @@ browserCanvasContext.lineWidth = 1; browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.stroke(); - + } /* Draw mouse candel and Raise Event. */ diff --git a/Volumes.js b/Volumes.js index 1e2415327..0c0117ce4 100644 --- a/Volumes.js +++ b/Volumes.js @@ -128,7 +128,7 @@ /* Get ready for plotting. */ recalculate(); - + dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () { recalculate(); }) @@ -567,7 +567,6 @@ volumePointB2 = transformThisPoint(volumePointB2, thisObject.container); volumePointB3 = transformThisPoint(volumePointB3, thisObject.container); volumePointB4 = transformThisPoint(volumePointB4, thisObject.container); - } calculateSells(coordinateSystem, thisObject.container.frame.height); // We try to see if it fits in the visible area. @@ -661,7 +660,7 @@ browserCanvasContext.lineWidth = 1; browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.stroke(); - + browserCanvasContext.beginPath(); browserCanvasContext.moveTo(volumePointB1.x, volumePointB1.y); @@ -686,7 +685,7 @@ browserCanvasContext.lineWidth = 1; browserCanvasContext.setLineDash([0, 0]) browserCanvasContext.stroke(); - + if (userPositionDate >= volume.begin && userPositionDate <= volume.end) { let buyInfo = {