events at coordinate system
This commit is contained in:
1 parent
b449ec4ad9
commit
7692e3685d
2 files changed
+56
-4
No files matched your search
+28
-2
@@ -57,7 +57,9 @@
|
||||
let dimmensionsChangedEventSubscriptionId
|
||||
let marketFilesUpdatedEventSubscriptionId
|
||||
let dailyFilesUpdatedEventSubscriptionId
|
||||
let scaleChangedEventSubscriptionId
|
||||
|
||||
let userPositionDate
|
||||
return thisObject;
|
||||
|
||||
function finalize() {
|
||||
@@ -85,6 +87,7 @@
|
||||
|
||||
thisObject.fitFunction = undefined
|
||||
|
||||
finalizeCoordinateSystem()
|
||||
coordinateSystem = undefined
|
||||
} catch (err) {
|
||||
|
||||
@@ -104,6 +107,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. */
|
||||
|
||||
@@ -139,6 +143,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()
|
||||
@@ -226,7 +242,9 @@
|
||||
}
|
||||
|
||||
function setCoordinateSystem(pCoordinateSystem) {
|
||||
finalizeCoordinateSystem()
|
||||
coordinateSystem = pCoordinateSystem
|
||||
initializeCoordinateSystem()
|
||||
}
|
||||
|
||||
function onDailyFileLoaded(event) {
|
||||
@@ -340,7 +358,11 @@
|
||||
if (candle.open < candle.close) { candle.direction = 'up'; }
|
||||
if (candle.open === candle.close) { candle.direction = 'side'; }
|
||||
|
||||
if (candle.begin >= farLeftDate.valueOf() && candle.end <= farRightDate.valueOf()) {
|
||||
|
||||
if (
|
||||
(candle.begin >= farLeftDate.valueOf() && candle.end <= farRightDate.valueOf()) &&
|
||||
(candle.begin >= coordinateSystem.min.x && candle.end <= coordinateSystem.max.x)
|
||||
) {
|
||||
|
||||
candles.push(candle);
|
||||
|
||||
@@ -416,7 +438,11 @@
|
||||
if (candle.open < candle.close) { candle.direction = 'up'; }
|
||||
if (candle.open === candle.close) { candle.direction = 'side'; }
|
||||
|
||||
if (candle.begin >= leftDate.valueOf() && candle.end <= rightDate.valueOf()) {
|
||||
if (
|
||||
(candle.begin >= leftDate.valueOf() && candle.end <= rightDate.valueOf()) &&
|
||||
(candle.begin >= coordinateSystem.min.x && candle.end <= coordinateSystem.max.x)
|
||||
)
|
||||
{
|
||||
|
||||
candles.push(candle);
|
||||
|
||||
|
||||
+28
-2
@@ -56,7 +56,9 @@
|
||||
let dimmensionsChangedEventSubscriptionId
|
||||
let marketFilesUpdatedEventSubscriptionId
|
||||
let dailyFilesUpdatedEventSubscriptionId
|
||||
let scaleChangedEventSubscriptionId
|
||||
|
||||
let userPositionDate
|
||||
return thisObject;
|
||||
|
||||
function finalize() {
|
||||
@@ -84,6 +86,7 @@
|
||||
|
||||
thisObject.fitFunction = undefined
|
||||
|
||||
finalizeCoordinateSystem()
|
||||
coordinateSystem = undefined
|
||||
} catch (err) {
|
||||
|
||||
@@ -103,6 +106,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. */
|
||||
|
||||
@@ -142,6 +146,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
function initializeCoordinateSystem() {
|
||||
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
|
||||
}
|
||||
|
||||
function finalizeCoordinateSystem() {
|
||||
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
|
||||
}
|
||||
|
||||
function onScaleChanged() {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
}
|
||||
|
||||
function onMouseOver(event) {
|
||||
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
|
||||
userPositionDate = userPosition.valueOf()
|
||||
@@ -249,7 +267,9 @@
|
||||
}
|
||||
|
||||
function setCoordinateSystem(pCoordinateSystem) {
|
||||
finalizeCoordinateSystem()
|
||||
coordinateSystem = pCoordinateSystem
|
||||
initializeCoordinateSystem()
|
||||
}
|
||||
|
||||
function onDailyFileLoaded(event) {
|
||||
@@ -353,7 +373,10 @@
|
||||
volume.begin = dailyFile[i][2];
|
||||
volume.end = dailyFile[i][3];
|
||||
|
||||
if (volume.begin >= farLeftDate.valueOf() && volume.end <= farRightDate.valueOf()) {
|
||||
if (
|
||||
(volume.begin >= farLeftDate.valueOf() && volume.end <= farRightDate.valueOf()) &&
|
||||
(volume.begin >= coordinateSystem.min.x && volume.end <= coordinateSystem.max.x)
|
||||
) {
|
||||
|
||||
volumes.push(volume);
|
||||
|
||||
@@ -424,7 +447,10 @@
|
||||
volume.begin = marketFile[i][2];
|
||||
volume.end = marketFile[i][3];
|
||||
|
||||
if (volume.begin >= leftDate.valueOf() && volume.end <= rightDate.valueOf()) {
|
||||
if (
|
||||
(volume.begin >= leftDate.valueOf() && volume.end <= rightDate.valueOf()) &&
|
||||
(volume.begin >= coordinateSystem.min.x && volume.end <= coordinateSystem.max.x)
|
||||
) {
|
||||
|
||||
volumes.push(volume);
|
||||
|
||||
|
||||
Reference in new issue
Block a user