Improvements at the Charting System
This commit is contained in:
1 parent
b92d650936
commit
0606ec5e37
27 files changed
+1022
-642
No files matched your search
@@ -17,6 +17,7 @@
|
||||
getContainer: getContainer,
|
||||
setTimeFrame: setTimeFrame,
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
draw: draw,
|
||||
recalculateScale: recalculateScale,
|
||||
|
||||
@@ -35,7 +36,7 @@
|
||||
container.initialize();
|
||||
thisObject.container = container;
|
||||
|
||||
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
|
||||
let coordinateSystem
|
||||
|
||||
let timeFrame; // This will hold the current Time Frame the user is at.
|
||||
let datetime; // This will hold the current Datetime the user is at.
|
||||
@@ -54,20 +55,23 @@
|
||||
let imageTakeProfitPhase;
|
||||
let imageRecord;
|
||||
|
||||
let onMouseOverEventSuscriptionId
|
||||
let zoomChangedEventSubscriptionId
|
||||
let offsetChangedEventSubscriptionId
|
||||
let dragFinishedEventSubscriptionId
|
||||
let dimmensionsChangedEventSubscriptionId
|
||||
let marketFilesUpdatedEventSubscriptionId
|
||||
let dailyFilesUpdatedEventSubscriptionId
|
||||
let scaleChangedEventSubscriptionId
|
||||
|
||||
let userPositionDate
|
||||
return thisObject;
|
||||
|
||||
function finalize() {
|
||||
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);
|
||||
@@ -93,13 +97,16 @@
|
||||
fileCursor = undefined;
|
||||
|
||||
thisObject.fitFunction = undefined
|
||||
|
||||
finalizeCoordinateSystem()
|
||||
coordinateSystem = undefined
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
|
||||
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -110,13 +117,13 @@
|
||||
|
||||
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. */
|
||||
|
||||
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster.
|
||||
|
||||
recalculateScale();
|
||||
|
||||
/* Now we set the right files according to current Period. */
|
||||
|
||||
marketFile = marketFiles.getFile(pTimeFrame);
|
||||
@@ -129,6 +136,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. */
|
||||
|
||||
@@ -137,7 +145,6 @@
|
||||
/* Ready for when dimmension changes. */
|
||||
|
||||
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
|
||||
recalculateScale()
|
||||
recalculate();
|
||||
})
|
||||
|
||||
@@ -155,6 +162,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
let container;
|
||||
/* First we check if this point is inside this space. */
|
||||
@@ -221,9 +245,13 @@
|
||||
}
|
||||
|
||||
function setDatetime(pDatetime) {
|
||||
|
||||
datetime = pDatetime;
|
||||
}
|
||||
|
||||
function setCoordinateSystem(pCoordinateSystem) {
|
||||
finalizeCoordinateSystem()
|
||||
coordinateSystem = pCoordinateSystem
|
||||
initializeCoordinateSystem()
|
||||
}
|
||||
|
||||
function onDailyFileLoaded(event) {
|
||||
@@ -360,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);
|
||||
|
||||
@@ -448,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);
|
||||
|
||||
@@ -502,9 +536,6 @@
|
||||
|
||||
try {
|
||||
|
||||
let userPosition = getUserPosition()
|
||||
let userPositionDate = userPosition.point.x
|
||||
|
||||
let record;
|
||||
|
||||
/* Now we calculate and plot the records */
|
||||
|
||||
Reference in new issue
Block a user