From c3010097c6adc3890da8282e98c703d3432ca614 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Jan 2020 22:05:00 +0100 Subject: [PATCH] no more getUserPosition --- SimulationExecution.js | 11 ++++++++--- Strategies.js | 12 ++++++++---- Trades.js | 12 ++++++++---- TradingSimulation.js | 12 ++++++++---- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/SimulationExecution.js b/SimulationExecution.js index 80def9f64..fa2891643 100644 --- a/SimulationExecution.js +++ b/SimulationExecution.js @@ -41,6 +41,7 @@ let previousNotesSetKey; + let onMouseOverEventSuscriptionId let offsetChangedEventSubscriptionId let filesUpdatedEventSubscriptionId let dimmensionsChangedEventSubscriptionId @@ -51,7 +52,7 @@ try { /* Stop listening to the necesary events. */ - + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId); fileSequence.eventHandler.stopListening(filesUpdatedEventSubscriptionId); thisObject.container.eventHandler.stopListening(dimmensionsChangedEventSubscriptionId) @@ -87,6 +88,7 @@ filesUpdatedEventSubscriptionId = fileSequence.eventHandler.listenToEvent("Files Updated", onFilesUpdated); // Only the first sequence is supported right now. offsetChangedEventSubscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent("Position Changed", onViewportPositionChanged); + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) /* Ready for when dimmension changes. */ @@ -101,6 +103,11 @@ } } + function onMouseOver(event) { + let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem) + userPositionDate = userPosition.valueOf() + } + function getContainer(point) { try { let container; @@ -347,8 +354,6 @@ function plotChart() { try { - let userPosition = getUserPosition() - let userPositionDate = userPosition.point.x let currentRecord let point = { diff --git a/Strategies.js b/Strategies.js index 4f8aa50eb..d511fb226 100644 --- a/Strategies.js +++ b/Strategies.js @@ -53,6 +53,7 @@ let strategies = []; let strategyImages = []; + let onMouseOverEventSuscriptionId let zoomChangedEventSubscriptionId let offsetChangedEventSubscriptionId let dragFinishedEventSubscriptionId @@ -68,7 +69,7 @@ if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); } /* Stop listening to the necesary events. */ - + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId); canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId); canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId); @@ -129,6 +130,7 @@ dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated); dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated); + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) /* Get ready for plotting. */ @@ -153,6 +155,11 @@ } } + function onMouseOver(event) { + let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem) + userPositionDate = userPosition.valueOf() + } + function getContainer(point) { try { @@ -483,9 +490,6 @@ try { - let userPosition = getUserPosition() - let userPositionDate = userPosition.point.x - thisObject.container.eventHandler.raiseEvent("Current Strategy Record Changed", undefined); let record; diff --git a/Trades.js b/Trades.js index daecc4c02..bfda0ef71 100644 --- a/Trades.js +++ b/Trades.js @@ -53,6 +53,7 @@ let trades = []; let headers; + let onMouseOverEventSuscriptionId let zoomChangedEventSubscriptionId let offsetChangedEventSubscriptionId let dragFinishedEventSubscriptionId @@ -68,7 +69,7 @@ if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); } /* Stop listening to the necesary events. */ - + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId); canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId); canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId); @@ -127,6 +128,7 @@ dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated); dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated); + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) /* Get ready for plotting. */ @@ -146,6 +148,11 @@ } } + function onMouseOver(event) { + let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem) + userPositionDate = userPosition.valueOf() + } + function getContainer(point) { try { @@ -464,9 +471,6 @@ try { - let userPosition = getUserPosition() - let userPositionDate = userPosition.point.x - thisObject.container.eventHandler.raiseEvent("Current Trade Record Changed", undefined); let record; diff --git a/TradingSimulation.js b/TradingSimulation.js index 98a85bd6b..66d879c98 100644 --- a/TradingSimulation.js +++ b/TradingSimulation.js @@ -55,6 +55,7 @@ let imageTakeProfitPhase; let imageRecord; + let onMouseOverEventSuscriptionId let zoomChangedEventSubscriptionId let offsetChangedEventSubscriptionId let dragFinishedEventSubscriptionId @@ -68,7 +69,7 @@ try { /* Stop listening to the necesary events. */ - + thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId); canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId); canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId); @@ -131,6 +132,7 @@ dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated); dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated); + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) /* Get ready for plotting. */ @@ -156,6 +158,11 @@ } } + function onMouseOver(event) { + let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem) + userPositionDate = userPosition.valueOf() + } + function getContainer(point) { let container; /* First we check if this point is inside this space. */ @@ -505,9 +512,6 @@ try { - let userPosition = getUserPosition() - let userPositionDate = userPosition.point.x - let record; /* Now we calculate and plot the records */