From 90314ffcf2177760af3002ca55d828744ae6d8d0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Jan 2020 19:54:34 +0100 Subject: [PATCH] Bug Fixed at Plotter when dragging Time Machine container --- ChartsSpace/PlottersManager.js | 2 +- ChartsSpace/TimeMachine.js | 2 +- ChartsSpace/TimelineChart.js | 2 +- Plotter.js | 31 +++++++++++++++++++------------ 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index f1b5728f1..a221e16eb 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -199,7 +199,7 @@ function newPlottersManager () { plotter = getNewPlotter(pProductCard.product.plotter.dataMine, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName) } - plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true) + plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 plotter.fitFunction = thisObject.fitFunction diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index e193efcab..1653d556e 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -284,7 +284,7 @@ function newTimeMachine () { timelineChart.payload.uiObject.setValue('Loading...') /* Setting up the new timeline chart. */ - timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true) + timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) timelineChart.container.fitFunction = thisObject.container.fitFunction timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 08e78d287..bbe6e5084 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -158,7 +158,7 @@ function newTimelineChart () { plotterManager = newPlottersManager() - plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true) + plotterManager.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) plotterManager.container.frame.position.x = 0 plotterManager.container.frame.position.y = 0 diff --git a/Plotter.js b/Plotter.js index 00fa2a607..a0cde53cc 100644 --- a/Plotter.js +++ b/Plotter.js @@ -58,6 +58,7 @@ function newPlotter () { let dimmensionsChangedEventSubscriptionId let marketFilesUpdatedEventSubscriptionId let dailyFilesUpdatedEventSubscriptionId + let onDisplaceEventSubscriptionId let logged = false return thisObject @@ -71,6 +72,7 @@ function newPlotter () { thisObject.container.eventHandler.stopListening(dimmensionsChangedEventSubscriptionId) marketFiles.eventHandler.stopListening(marketFilesUpdatedEventSubscriptionId) dailyFiles.eventHandler.stopListening(dailyFilesUpdatedEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onDisplaceEventSubscriptionId) /* Clear References */ marketFiles = undefined @@ -120,6 +122,7 @@ function newPlotter () { dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent('Drag Finished', onDragFinished) marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent('Files Updated', onMarketFilesUpdated) dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent('Files Updated', onDailyFilesUpdated) + onDisplaceEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onDisplace', onDisplace) /* Get ready for plotting. */ recalculate() @@ -783,20 +786,24 @@ function newPlotter () { } } + function onDisplace (event) { + recalculateAll(event) + } + function onOffsetChanged (event) { - try { - mustRecalculateDataPoints = true - if (event !== undefined) { - if (event.recalculate === true) { - recalculate() - return - } - } - if (Math.random() * 100 > 95) { + recalculateAll(event) + } + + function recalculateAll (event) { + mustRecalculateDataPoints = true + if (event !== undefined) { + if (event.recalculate === true) { recalculate() - }; - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onOffsetChanged -> err = ' + err.stack) } + return + } + } + if (Math.random() * 100 > 95) { + recalculate() } } }