From 73b9458396222a316892ea7222bcdf765ccd27f6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 19:13:10 +0100 Subject: [PATCH] coordinateSystem going down to Plotters --- Candles.js | 15 +++++++++------ Volumes.js | 12 +++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Candles.js b/Candles.js index 008457f36..9a2303e47 100644 --- a/Candles.js +++ b/Candles.js @@ -17,6 +17,7 @@ getContainer: getContainer, setTimeFrame: setTimeFrame, setDatetime: setDatetime, + setCoordinateSystem: setCoordinateSystem, draw: draw, recalculateScale: recalculateScale, @@ -34,7 +35,7 @@ thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) - let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem let timeFrame; // This will hold the current Time Frame the user is at. let datetime; // This will hold the current Datetime the user is at. @@ -82,13 +83,15 @@ fileCursor = undefined; thisObject.fitFunction = undefined + + coordinateSystem = undefined } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); } } } - function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) { + function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) { try { @@ -99,13 +102,12 @@ datetime = pDatetime; timeFrame = pTimeFrame; + coordinateSystem = pCoordinateSystem /* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */ marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster. - recalculateScale(); - /* Now we set the right files according to current Period. */ marketFile = marketFiles.getFile(pTimeFrame); @@ -124,7 +126,6 @@ recalculate(); dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () { - recalculateScale() recalculate(); }) @@ -214,9 +215,11 @@ } function setDatetime(pDatetime) { - datetime = pDatetime; + } + function setCoordinateSystem(pCoordinateSystem) { + coordinateSystem = pCoordinateSystem } function onDailyFileLoaded(event) { diff --git a/Volumes.js b/Volumes.js index fa7daab72..82521b61b 100644 --- a/Volumes.js +++ b/Volumes.js @@ -21,6 +21,7 @@ getContainer: getContainer, setTimeFrame: setTimeFrame, setDatetime: setDatetime, + setCoordinateSystem: setCoordinateSystem, recalculateScale: recalculateScale, draw: draw }; @@ -30,7 +31,7 @@ thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) - let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not. + let coordinateSystem let plotAreaFrame = newCoordinateSystem(); // This chart uses this extra object. let timeFrame; // This will hold the current Time Frame the user is at. @@ -81,13 +82,15 @@ fileCursor = undefined; thisObject.fitFunction = undefined + + coordinateSystem = undefined } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); } } } - function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) { + function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) { try { @@ -98,6 +101,7 @@ datetime = pDatetime; timeFrame = pTimeFrame; + coordinateSystem = pCoordinateSystem /* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */ @@ -234,9 +238,11 @@ } function setDatetime(pDatetime) { - datetime = pDatetime; + } + function setCoordinateSystem(pCoordinateSystem) { + coordinateSystem = pCoordinateSystem } function onDailyFileLoaded(event) {