Coordinate System raising events when scale changes

This commit is contained in:
Luis Fernando Molina committed 2020-01-31 11:33:07 +01:00
1 parent 58cfd502e2
commit 9cc7e1ccd9
6 files changed
+49 -13

No files matched your search

+18
View File
@@ -52,6 +52,7 @@ function newPlotter () {
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let onDisplaceEventSubscriptionId
let scaleChangedEventSubscriptionId
let logged = false
return thisObject
@@ -78,6 +79,7 @@ function newPlotter () {
marketFile = undefined
fileCursor = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
slotCoordinateSystem = undefined
plotterModuleConfig = undefined
@@ -99,6 +101,7 @@ function newPlotter () {
datetime = pDatetime
timeFrame = pTimeFrame
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
productDefinition = pProductDefinition
@@ -131,6 +134,19 @@ function newPlotter () {
}
}
function initializeCoordinateSystem () {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem () {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged () {
mustRecalculateDataPoints = true
recalculate()
}
function onMouseOver (event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
@@ -208,7 +224,9 @@ function newPlotter () {
}
function setCoordinateSystem (pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded (event) {