events at coordinate system

This commit is contained in:
Luis Fernando Molina committed 2020-01-31 11:47:23 +01:00
1 parent c3010097c6
commit 7752458a91
4 files changed
+96 -6

No files matched your search

+18
View File
@@ -45,7 +45,9 @@
let offsetChangedEventSubscriptionId
let filesUpdatedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
@@ -68,6 +70,7 @@
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] ' + MODULE_NAME + ' -> finalize -> err = " + err.stack.stack); }
@@ -81,6 +84,7 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
fileSequence = pStorage.fileSequences[0];
@@ -103,6 +107,18 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
@@ -137,7 +153,9 @@
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onViewportPositionChanged() {
+26 -2
View File
@@ -60,7 +60,9 @@
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
@@ -92,6 +94,7 @@
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
@@ -113,6 +116,7 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
@@ -155,6 +159,18 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
@@ -246,7 +262,9 @@
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -367,7 +385,10 @@
record.beginRate = dailyFile[i][4];
record.endRate = dailyFile[i][5];
if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) {
if (
(record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
strategies.push(record);
@@ -439,7 +460,10 @@
strategies.push(record);
if (datetime.valueOf() >= record.begin && datetime.valueOf() <= record.end) {
if (
(record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
thisObject.currentRecord = record;
thisObject.container.eventHandler.raiseEvent("Current Strategy Changed", thisObject.currentRecord);
+26 -2
View File
@@ -60,7 +60,9 @@
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
@@ -90,6 +92,7 @@
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
@@ -111,6 +114,7 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
@@ -148,6 +152,18 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
@@ -239,7 +255,9 @@
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -354,7 +372,10 @@
record.endRate = dailyFile[i][5];
record.exitType = dailyFile[i][6];
if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) {
if (
(record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
trades.push(record);
@@ -416,7 +437,10 @@
record.endRate = marketFile[i][5];
record.exitType = marketFile[i][6];
if (record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) {
if (
(record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
trades.push(record);
+26 -2
View File
@@ -62,7 +62,9 @@
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
@@ -96,6 +98,7 @@
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
@@ -115,6 +118,7 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
@@ -158,6 +162,18 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
@@ -233,7 +249,9 @@
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -370,7 +388,10 @@
record.positionPeriods = dailyFile[i][34];
record.positionDays = dailyFile[i][35];
if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) {
if (
(record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
records.push(record);
@@ -458,7 +479,10 @@
record.positionPeriods = marketFile[i][34];
record.positionDays = marketFile[i][35];
if (record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) {
if (
(record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
records.push(record);