From 38cf1c5455c2e9b68b41366812e250bcbdc9e158 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 16 Mar 2020 14:36:17 +0100 Subject: [PATCH] Panels fixes --- CanvasApp/Scales/RateScale.js | 7 +-- CanvasApp/Utilities.js | 9 +++ .../BollingerBandsPanel.js | 16 +++-- .../Plotters-Candles-Volumes/CandlePanel.js | 59 +++++++++++++++++++ .../Plotters-Candles-Volumes/VolumePanel.js | 36 +++++++++++ 5 files changed, 117 insertions(+), 10 deletions(-) diff --git a/CanvasApp/Scales/RateScale.js b/CanvasApp/Scales/RateScale.js index 2c728aa11..8e208d9b3 100644 --- a/CanvasApp/Scales/RateScale.js +++ b/CanvasApp/Scales/RateScale.js @@ -487,12 +487,7 @@ function newRateScale () { rate = coordinateSystem.max.y } - let decimals = 2 - if (rate < 1) { decimals = 4 } - if (Math.trunc(rate * 100) < 1) { decimals = 6 } - if (Math.trunc(rate * 10000) < 1) { decimals = 8 } - if (Math.trunc(rate * 1000000) < 1) { decimals = 10 } - let label = (rate - Math.trunc(rate)).toFixed(decimals) + let label = dynamicDecimals(rate) let labelArray = label.split('.') let label1 = thisObject.payload.node.payload.parentNode.name let label2 = (Math.trunc(rate)).toLocaleString() diff --git a/CanvasApp/Utilities.js b/CanvasApp/Utilities.js index 2588156b9..8b4262173 100644 --- a/CanvasApp/Utilities.js +++ b/CanvasApp/Utilities.js @@ -22,6 +22,15 @@ function drawContainerBackground (container, color, opacity, fitFunction) { browserCanvasContext.fill() } +function dynamicDecimals (value) { + let decimals = 2 + if (value < 1) { decimals = 4 } + if (Math.trunc(value * 100) < 1) { decimals = 6 } + if (Math.trunc(value * 10000) < 1) { decimals = 8 } + if (Math.trunc(value * 1000000) < 1) { decimals = 10 } + return (value - Math.trunc(value)).toFixed(decimals) +} + function savePropertyAtNodeConfig (payload, propertyName, value) { try { let code = JSON.parse(payload.node.code) diff --git a/Legacy-Code/Masters/plotters/Plotters-Bollinger-Bands/BollingerBandsPanel.js b/Legacy-Code/Masters/plotters/Plotters-Bollinger-Bands/BollingerBandsPanel.js index 4214b0a1b..a6c50a880 100644 --- a/Legacy-Code/Masters/plotters/Plotters-Bollinger-Bands/BollingerBandsPanel.js +++ b/Legacy-Code/Masters/plotters/Plotters-Bollinger-Bands/BollingerBandsPanel.js @@ -118,8 +118,6 @@ function newMastersPlottersBollingerBandsBollingerBandsBollingerBandsPanel () { y: Y_AXIS - currentBand.rightBodyHeight / 2 + currentBand.bottomDelta / 4 }; - - /* Extra bounderies due to constrained space */ const upperLimit = frameTitleHeight + frameBodyHeight * 0.15; @@ -131,6 +129,15 @@ function newMastersPlottersBollingerBandsBollingerBandsBollingerBandsPanel () { if (bandPoint2.y < upperLimit) { bandPoint2.y = upperLimit; } if (bandPoint3.y < upperLimit) { bandPoint3.y = upperLimit; } + const leftLimit = thisObject.container.frame.width * 0.40; + const rightLimit = thisObject.container.frame.width * 0.60; + + if (bandPoint1.x < leftLimit) { bandPoint1.x = leftLimit; } + if (bandPoint2.x < leftLimit) { bandPoint2.x = leftLimit; } + + if (bandPoint3.x > rightLimit) { bandPoint3.x = rightLimit; } + if (bandPoint4.x > rightLimit) { bandPoint4.x = rightLimit; } + bandPoint1 = thisObject.container.frame.frameThisPoint(bandPoint1); bandPoint2 = thisObject.container.frame.frameThisPoint(bandPoint2); bandPoint3 = thisObject.container.frame.frameThisPoint(bandPoint3); @@ -213,9 +220,10 @@ function newMastersPlottersBollingerBandsBollingerBandsBollingerBandsPanel () { browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY + ' Saira'; - let label = '' + labelToPrint; + let label = labelToPrint if (isNaN(label) === false) { - label = Number(label).toLocaleString(); + label = dynamicDecimals(labelToPrint) + label = label.toLocaleString(); } let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO; diff --git a/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/CandlePanel.js b/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/CandlePanel.js index cd7240781..1cb8ba1b3 100644 --- a/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/CandlePanel.js +++ b/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/CandlePanel.js @@ -202,6 +202,65 @@ function newMastersPlottersCandlesVolumesCandlesCandlePanel() { } + const leftLimit = thisObject.container.frame.width * 0.40; + const rightLimit = thisObject.container.frame.width * 0.60; + + if (candlePoint1.x < leftLimit) { + + candlePoint1.x = leftLimit; + candlePoint4.x = leftLimit; + + } + + if (stickPoint1.x < leftLimit) { + + stickPoint1.x = leftLimit; + stickPoint4.x = leftLimit; + + } + + if (candlePoint4.x < leftLimit) { + + candlePoint4.x = leftLimit; + candlePoint1.x = leftLimit; + + } + + if (stickPoint4.x < leftLimit) { + + stickPoint4.x = leftLimit; + stickPoint1.x = leftLimit; + + } + + if (candlePoint2.x > rightLimit) { + + candlePoint2.x = rightLimit; + candlePoint3.x = rightLimit; + + } + + if (stickPoint2.x > rightLimit) { + + stickPoint2.x = rightLimit; + stickPoint3.x = rightLimit; + + } + + if (candlePoint3.x > rightLimit) { + + candlePoint3.x = rightLimit; + candlePoint2.x = rightLimit; + + } + + if (stickPoint3.x > rightLimit) { + + stickPoint3.x = rightLimit; + stickPoint2.x = rightLimit; + + } + candlePoint1 = thisObject.container.frame.frameThisPoint(candlePoint1); candlePoint2 = thisObject.container.frame.frameThisPoint(candlePoint2); diff --git a/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/VolumePanel.js b/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/VolumePanel.js index 0d872ec4f..60854383e 100644 --- a/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/VolumePanel.js +++ b/Legacy-Code/Masters/plotters/Plotters-Candles-Volumes/VolumePanel.js @@ -118,6 +118,28 @@ function newMastersPlottersCandlesVolumesVolumesVolumePanel() { y: Y_AXIS_BUY }; + /* Extra bounderies due to constrained space */ + + const upperLimit = frameTitleHeight + frameBodyHeight * 0.15; + const downLimit = frameTitleHeight + frameBodyHeight * 0.85; + + const leftLimit = thisObject.container.frame.width * 0.40; + const rightLimit = thisObject.container.frame.width * 0.60; + + if (buyVolumePoint1.y < downLimit) { buyVolumePoint1.y = downLimit; } + if (buyVolumePoint4.y < downLimit) { buyVolumePoint4.y = downLimit; } + + if (buyVolumePoint2.y < upperLimit) { buyVolumePoint2.y = upperLimit; } + if (buyVolumePoint3.y < upperLimit) { buyVolumePoint3.y = upperLimit; } + + if (buyVolumePoint1.x < leftLimit) { buyVolumePoint1.x = leftLimit; } + if (buyVolumePoint2.x < leftLimit) { buyVolumePoint2.x = leftLimit; } + + if (buyVolumePoint3.x > rightLimit) { buyVolumePoint3.x = rightLimit; } + if (buyVolumePoint4.x > rightLimit) { buyVolumePoint4.x = rightLimit; } + + + buyVolumePoint1 = thisObject.container.frame.fitIntoFrame(buyVolumePoint1); buyVolumePoint2 = thisObject.container.frame.fitIntoFrame(buyVolumePoint2); buyVolumePoint3 = thisObject.container.frame.fitIntoFrame(buyVolumePoint3); @@ -153,6 +175,18 @@ function newMastersPlottersCandlesVolumesVolumesVolumePanel() { y: Y_AXIS_SELL }; + if (sellVolumePoint1.y < upperLimit) { sellVolumePoint1.y = upperLimit; } + if (sellVolumePoint4.y < upperLimit) { sellVolumePoint4.y = upperLimit; } + + if (sellVolumePoint2.y > downLimit) { sellVolumePoint2.y = downLimit; } + if (sellVolumePoint3.y > downLimit) { sellVolumePoint3.y = downLimit; } + + if (sellVolumePoint1.x < leftLimit) { sellVolumePoint1.x = leftLimit; } + if (sellVolumePoint2.x < leftLimit) { sellVolumePoint2.x = leftLimit; } + + if (sellVolumePoint3.x > rightLimit) { sellVolumePoint3.x = rightLimit; } + if (sellVolumePoint4.x > rightLimit) { sellVolumePoint4.x = rightLimit; } + sellVolumePoint1 = thisObject.container.frame.fitIntoFrame(sellVolumePoint1); sellVolumePoint2 = thisObject.container.frame.fitIntoFrame(sellVolumePoint2); sellVolumePoint3 = thisObject.container.frame.fitIntoFrame(sellVolumePoint3); @@ -168,6 +202,8 @@ function newMastersPlottersCandlesVolumesVolumesVolumePanel() { sellVolumePoint3 = thisObject.fitFunction(sellVolumePoint3) sellVolumePoint4 = thisObject.fitFunction(sellVolumePoint4) + + const OPACITY = '0.40'; browserCanvasContext.beginPath();