Bug Fixes and Improvement in Legacy Plotters
This commit is contained in:
1 parent
0606ec5e37
commit
785f068f0e
11 files changed
+86
-592
No files matched your search
@@ -19,7 +19,6 @@
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
draw: draw,
|
||||
recalculateScale: recalculateScale,
|
||||
|
||||
/* Events declared outside the plotter. */
|
||||
|
||||
@@ -457,36 +456,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScale -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
@@ -553,6 +522,26 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
let diffA = bandPoint2.y - canvas.chartSpace.viewport.visibleArea.bottomLeft.y
|
||||
if (diffA > 0) {
|
||||
bandPoint1.y = bandPoint1.y - diffA
|
||||
bandPoint2.y = bandPoint2.y - diffA
|
||||
bandPoint3.y = bandPoint3.y - diffA
|
||||
bandPoint4.y = bandPoint4.y - diffA
|
||||
bandPoint5.y = bandPoint5.y - diffA
|
||||
bandPoint6.y = bandPoint6.y - diffA
|
||||
}
|
||||
|
||||
let diffB = bandPoint1.y - canvas.chartSpace.viewport.visibleArea.topLeft.y
|
||||
if (diffB < 0) {
|
||||
bandPoint1.y = bandPoint1.y - diffB
|
||||
bandPoint2.y = bandPoint2.y - diffB
|
||||
bandPoint3.y = bandPoint3.y - diffB
|
||||
bandPoint4.y = bandPoint4.y - diffB
|
||||
bandPoint5.y = bandPoint5.y - diffB
|
||||
bandPoint6.y = bandPoint6.y - diffB
|
||||
}
|
||||
|
||||
bandPoint1 = canvas.chartSpace.viewport.fitIntoVisibleArea(bandPoint1);
|
||||
bandPoint2 = canvas.chartSpace.viewport.fitIntoVisibleArea(bandPoint2);
|
||||
bandPoint3 = canvas.chartSpace.viewport.fitIntoVisibleArea(bandPoint3);
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
logger.fileName = MODULE_NAME;
|
||||
|
||||
let thisObject = {
|
||||
|
||||
// Main functions and properties.
|
||||
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
container: undefined,
|
||||
@@ -19,14 +16,7 @@
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
draw: draw,
|
||||
recalculateScale: recalculateScale,
|
||||
|
||||
/* Events declared outside the plotter. */
|
||||
|
||||
onDailyFileLoaded: onDailyFileLoaded,
|
||||
|
||||
// Secondary functions and properties.
|
||||
|
||||
currentCandle: undefined
|
||||
};
|
||||
|
||||
@@ -461,36 +451,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScale -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
@@ -532,16 +492,6 @@
|
||||
candle.candlePoint3 = transformThisPoint(candle.candlePoint3, thisObject.container);
|
||||
candle.candlePoint4 = transformThisPoint(candle.candlePoint4, thisObject.container);
|
||||
|
||||
candle.candlePoint1 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint1);
|
||||
candle.candlePoint2 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint2);
|
||||
candle.candlePoint3 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint3);
|
||||
candle.candlePoint4 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint4);
|
||||
|
||||
candle.candlePoint1 = thisObject.fitFunction(candle.candlePoint1);
|
||||
candle.candlePoint2 = thisObject.fitFunction(candle.candlePoint2);
|
||||
candle.candlePoint3 = thisObject.fitFunction(candle.candlePoint3);
|
||||
candle.candlePoint4 = thisObject.fitFunction(candle.candlePoint4);
|
||||
|
||||
candle.stickPoint1 = {
|
||||
x: candle.begin + timeFrame / 7 * 3.2,
|
||||
y: candle.max
|
||||
@@ -572,6 +522,42 @@
|
||||
candle.stickPoint3 = transformThisPoint(candle.stickPoint3, thisObject.container);
|
||||
candle.stickPoint4 = transformThisPoint(candle.stickPoint4, thisObject.container);
|
||||
|
||||
let diffA = candle.stickPoint3.y - canvas.chartSpace.viewport.visibleArea.bottomLeft.y
|
||||
if (diffA > 0) {
|
||||
candle.candlePoint1.y = candle.candlePoint1.y - diffA
|
||||
candle.candlePoint2.y = candle.candlePoint2.y - diffA
|
||||
candle.candlePoint3.y = candle.candlePoint3.y - diffA
|
||||
candle.candlePoint4.y = candle.candlePoint4.y - diffA
|
||||
|
||||
candle.stickPoint1.y = candle.stickPoint1.y - diffA
|
||||
candle.stickPoint2.y = candle.stickPoint2.y - diffA
|
||||
candle.stickPoint3.y = candle.stickPoint3.y - diffA
|
||||
candle.stickPoint4.y = candle.stickPoint4.y - diffA
|
||||
}
|
||||
|
||||
let diffB = candle.stickPoint1.y - canvas.chartSpace.viewport.visibleArea.topLeft.y
|
||||
if (diffB < 0) {
|
||||
candle.candlePoint1.y = candle.candlePoint1.y - diffB
|
||||
candle.candlePoint2.y = candle.candlePoint2.y - diffB
|
||||
candle.candlePoint3.y = candle.candlePoint3.y - diffB
|
||||
candle.candlePoint4.y = candle.candlePoint4.y - diffB
|
||||
|
||||
candle.stickPoint1.y = candle.stickPoint1.y - diffB
|
||||
candle.stickPoint2.y = candle.stickPoint2.y - diffB
|
||||
candle.stickPoint3.y = candle.stickPoint3.y - diffB
|
||||
candle.stickPoint4.y = candle.stickPoint4.y - diffB
|
||||
}
|
||||
|
||||
candle.candlePoint1 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint1);
|
||||
candle.candlePoint2 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint2);
|
||||
candle.candlePoint3 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint3);
|
||||
candle.candlePoint4 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.candlePoint4);
|
||||
|
||||
candle.candlePoint1 = thisObject.fitFunction(candle.candlePoint1);
|
||||
candle.candlePoint2 = thisObject.fitFunction(candle.candlePoint2);
|
||||
candle.candlePoint3 = thisObject.fitFunction(candle.candlePoint3);
|
||||
candle.candlePoint4 = thisObject.fitFunction(candle.candlePoint4);
|
||||
|
||||
candle.stickPoint1 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.stickPoint1);
|
||||
candle.stickPoint2 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.stickPoint2);
|
||||
candle.stickPoint3 = canvas.chartSpace.viewport.fitIntoVisibleArea(candle.stickPoint3);
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
thisObject.container.initialize(MODULE_NAME)
|
||||
|
||||
let coordinateSystem
|
||||
let plotAreaFrame = newCoordinateSystem(); // This chart uses this extra object.
|
||||
|
||||
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.
|
||||
@@ -128,14 +127,10 @@
|
||||
|
||||
/* Get ready for plotting. */
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
|
||||
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
})
|
||||
|
||||
callBackFunction();
|
||||
@@ -155,9 +150,7 @@
|
||||
}
|
||||
|
||||
function onScaleChanged() {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
}
|
||||
|
||||
function onMouseOver(event) {
|
||||
@@ -166,11 +159,7 @@
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
@@ -203,9 +192,7 @@
|
||||
let newMarketFile = marketFiles.getFile(timeFrame);
|
||||
if (newMarketFile !== undefined) {
|
||||
marketFile = newMarketFile;
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] onMarketFilesUpdated -> err = " + err.stack); }
|
||||
@@ -217,9 +204,7 @@
|
||||
let newFileCursor = dailyFiles.getFileCursor(timeFrame);
|
||||
if (newFileCursor !== undefined) {
|
||||
fileCursor = newFileCursor;
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] onDailyFilesUpdated -> err = " + err.stack); }
|
||||
@@ -274,21 +259,9 @@
|
||||
|
||||
function onDailyFileLoaded(event) {
|
||||
|
||||
try {
|
||||
|
||||
if (event.currentValue === event.totalValue) {
|
||||
|
||||
/* This happens only when all of the files in the cursor have been loaded. */
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] onDailyFileLoaded -> err = " + err.stack); }
|
||||
if (event.currentValue === event.totalValue) {
|
||||
/* This happens only when all of the files in the cursor have been loaded. */
|
||||
recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,25 +282,12 @@
|
||||
}
|
||||
|
||||
function recalculate() {
|
||||
|
||||
try {
|
||||
|
||||
if (timeFrame >= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
recalculateUsingMarketFiles();
|
||||
|
||||
} else {
|
||||
|
||||
recalculateUsingDailyFiles();
|
||||
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.raiseEvent("Volumes Changed", volumes);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculate -> err = " + err.stack); }
|
||||
if (timeFrame >= _1_HOUR_IN_MILISECONDS) {
|
||||
recalculateUsingMarketFiles();
|
||||
} else {
|
||||
recalculateUsingDailyFiles();
|
||||
}
|
||||
thisObject.container.eventHandler.raiseEvent("Volumes Changed", volumes);
|
||||
}
|
||||
|
||||
function recalculateUsingDailyFiles() {
|
||||
@@ -470,87 +430,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScaleX() {
|
||||
|
||||
try {
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf()
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf()
|
||||
};
|
||||
|
||||
coordinateSystem.initializeX(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width
|
||||
);
|
||||
|
||||
plotAreaFrame.initializeX(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScaleX -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScaleY() {
|
||||
|
||||
try {
|
||||
|
||||
let minValue = {
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
y: 0
|
||||
};
|
||||
|
||||
let timeFrameRatio = ONE_DAY_IN_MILISECONDS / timeFrame;
|
||||
|
||||
maxValue.y = getMaxVolume() / (timeFrameRatio / 2.5);
|
||||
|
||||
coordinateSystem.initializeY(
|
||||
minValue,
|
||||
maxValue,
|
||||
canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y
|
||||
);
|
||||
|
||||
plotAreaFrame.initializeY(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
function getMaxVolume() {
|
||||
|
||||
let maxValue = 0;
|
||||
|
||||
for (let i = 0; i < scaleFile.length; i++) {
|
||||
|
||||
let currentMax = (scaleFile[i][0] + scaleFile[i][1]) * 4;
|
||||
|
||||
if (maxValue < currentMax) {
|
||||
maxValue = currentMax;
|
||||
}
|
||||
}
|
||||
|
||||
return maxValue;
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScaleY -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
@@ -635,19 +514,14 @@
|
||||
|
||||
}
|
||||
|
||||
if (calculateBuys(plotAreaFrame, thisObject.container.frame.height) === false) { continue; } // We try to see if it fits in the visible area.
|
||||
|
||||
if (volumePointA1.y > canvas.chartSpace.viewport.visibleArea.bottomLeft.y && frameHeightInViewPort > visibleHeight * 2 / 3) {
|
||||
|
||||
if (calculateBuys(coordinateSystem, visibleHeight) === false) { continue; } // We snap t to the view port.
|
||||
|
||||
/* Now we set the real value of y. */
|
||||
|
||||
volumePointA1.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y;
|
||||
volumePointA2.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y - volume.amountBuy * coordinateSystem.scale.y;
|
||||
volumePointA3.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y - volume.amountBuy * coordinateSystem.scale.y;
|
||||
volumePointA4.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y;
|
||||
if (calculateBuys(coordinateSystem, thisObject.container.frame.height) === false) { continue; } // We try to see if it fits in the visible area.
|
||||
|
||||
let diffA = volumePointA1.y - canvas.chartSpace.viewport.visibleArea.bottomLeft.y
|
||||
if (diffA > 0) {
|
||||
volumePointA1.y = volumePointA1.y - diffA
|
||||
volumePointA2.y = volumePointA2.y - diffA
|
||||
volumePointA3.y = volumePointA3.y - diffA
|
||||
volumePointA4.y = volumePointA4.y - diffA
|
||||
}
|
||||
|
||||
let volumePointB1;
|
||||
@@ -689,19 +563,14 @@
|
||||
|
||||
}
|
||||
|
||||
calculateSells(plotAreaFrame, thisObject.container.frame.height); // We try to see if it fits in the visible area.
|
||||
|
||||
if (volumePointB1.y < canvas.chartSpace.viewport.visibleArea.topLeft.y && frameHeightInViewPort > visibleHeight * 2 / 3) {
|
||||
|
||||
calculateSells(coordinateSystem, visibleHeight); // We snap it to the view port.
|
||||
|
||||
/* Now we set the real value of y. */
|
||||
|
||||
volumePointB1.y = canvas.chartSpace.viewport.visibleArea.topLeft.y;
|
||||
volumePointB2.y = canvas.chartSpace.viewport.visibleArea.topLeft.y + volume.amountSell * coordinateSystem.scale.y;
|
||||
volumePointB3.y = canvas.chartSpace.viewport.visibleArea.topLeft.y + volume.amountSell * coordinateSystem.scale.y;
|
||||
volumePointB4.y = canvas.chartSpace.viewport.visibleArea.topLeft.y;
|
||||
calculateSells(coordinateSystem, thisObject.container.frame.height); // We try to see if it fits in the visible area.
|
||||
|
||||
let diffB = volumePointB1.y - canvas.chartSpace.viewport.visibleArea.topLeft.y
|
||||
if (diffB < 0) {
|
||||
volumePointB1.y = volumePointB1.y - diffB
|
||||
volumePointB2.y = volumePointB2.y - diffB
|
||||
volumePointB3.y = volumePointB3.y - diffB
|
||||
volumePointB4.y = volumePointB4.y - diffB
|
||||
}
|
||||
|
||||
/* We put a wider base */
|
||||
@@ -830,7 +699,6 @@
|
||||
thisObject.container.eventHandler.raiseEvent("Current Record Changed", currentVolume);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -842,17 +710,7 @@
|
||||
}
|
||||
|
||||
function onViewportZoomChanged(event) {
|
||||
|
||||
try {
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] onViewportZoomChanged -> err = " + err.stack); }
|
||||
}
|
||||
recalculate()
|
||||
}
|
||||
|
||||
function onViewportPositionChanged(event) {
|
||||
@@ -860,16 +718,12 @@
|
||||
try {
|
||||
if (event !== undefined) {
|
||||
if (event.recalculate === true) {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
return
|
||||
}
|
||||
}
|
||||
if (Math.random() * 100 > 95) {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
};
|
||||
|
||||
} catch (err) {
|
||||
@@ -879,17 +733,7 @@
|
||||
}
|
||||
|
||||
function onDragFinished() {
|
||||
|
||||
try {
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] onDragFinished -> err = " + err.stack); }
|
||||
}
|
||||
recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
setTimeFrame: setTimeFrame,
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
recalculateScale: recalculateScale,
|
||||
draw: draw,
|
||||
|
||||
// Secondary functions and properties.
|
||||
@@ -503,37 +502,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScale -> err = " + err.stack); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
setTimeFrame: setTimeFrame,
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
recalculateScale: recalculateScale,
|
||||
draw: draw
|
||||
};
|
||||
|
||||
@@ -33,7 +32,6 @@
|
||||
thisObject.container = container;
|
||||
|
||||
let coordinateSystem
|
||||
let coordinateSystemFrame = newCoordinateSystem(); // This chart uses this extra object.
|
||||
|
||||
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.
|
||||
@@ -129,14 +127,10 @@
|
||||
|
||||
/* Get ready for plotting. */
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
})
|
||||
|
||||
callBackFunction();
|
||||
@@ -158,9 +152,7 @@
|
||||
}
|
||||
|
||||
function onScaleChanged() {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
}
|
||||
|
||||
function onMouseOver(event) {
|
||||
@@ -168,14 +160,6 @@
|
||||
userPositionDate = userPosition.valueOf()
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
}
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
try {
|
||||
@@ -280,11 +264,7 @@
|
||||
if (event.currentValue === event.totalValue) {
|
||||
|
||||
/* This happens only when all of the files in the cursor have been loaded. */
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
@@ -494,96 +474,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScaleX() {
|
||||
|
||||
try {
|
||||
|
||||
var minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf()
|
||||
};
|
||||
|
||||
var maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf()
|
||||
};
|
||||
|
||||
coordinateSystem.initializeX(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width
|
||||
);
|
||||
|
||||
coordinateSystemFrame.initializeX(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScaleX -> err = " + err.stack); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScaleY() {
|
||||
|
||||
try {
|
||||
|
||||
var minValue = {
|
||||
y: 0
|
||||
};
|
||||
|
||||
var maxValue = {
|
||||
y: 0
|
||||
};
|
||||
|
||||
let timeFrameRatio = ONE_DAY_IN_MILISECONDS / timeFrame;
|
||||
|
||||
maxValue.y = getMaxVolume() / (timeFrameRatio / 2.5);
|
||||
|
||||
coordinateSystem.initializeY(
|
||||
minValue,
|
||||
maxValue,
|
||||
canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y
|
||||
);
|
||||
|
||||
coordinateSystemFrame.initializeY(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
function getMaxVolume() {
|
||||
|
||||
try {
|
||||
|
||||
let maxValue = 0;
|
||||
|
||||
for (var i = 0; i < scaleFile.length; i++) {
|
||||
|
||||
let currentMax = (scaleFile[i][5] + scaleFile[i][6]) * 8;
|
||||
|
||||
if (maxValue < currentMax) {
|
||||
maxValue = currentMax;
|
||||
}
|
||||
}
|
||||
|
||||
return maxValue;
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScaleY -> getMaxVolume -> err = " + err.stack); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScaleY -> err = " + err.stack); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
@@ -663,7 +553,7 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
if (calculateBuys(coordinateSystemFrame, thisObject.container.frame.height) === false) { continue; } // We try to see if it fits in the visible area.
|
||||
if (calculateBuys(coordinateSystem, thisObject.container.frame.height) === false) { continue; } // We try to see if it fits in the visible area.
|
||||
|
||||
if (volumeBarPointA1.y > canvas.chartSpace.viewport.visibleArea.bottomLeft.y && frameHeightInViewPort > visibleHeight * 2 / 3) {
|
||||
|
||||
@@ -720,7 +610,7 @@
|
||||
|
||||
}
|
||||
|
||||
calculateSells(coordinateSystemFrame, thisObject.container.frame.height); // We try to see if it fits in the visible area.
|
||||
calculateSells(coordinateSystem, thisObject.container.frame.height); // We try to see if it fits in the visible area.
|
||||
|
||||
if (volumeBarPointB1.y < canvas.chartSpace.viewport.visibleArea.topLeft.y && frameHeightInViewPort > visibleHeight * 2 / 3) {
|
||||
|
||||
@@ -821,33 +711,11 @@
|
||||
}
|
||||
|
||||
function onViewportZoomChanged(event) {
|
||||
|
||||
try {
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] onViewportZoomChanged -> err = " + err.stack); }
|
||||
|
||||
}
|
||||
recalculate();
|
||||
}
|
||||
|
||||
function onDragFinished() {
|
||||
|
||||
try {
|
||||
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] onDragFinished -> err = " + err.stack); }
|
||||
|
||||
}
|
||||
recalculate();
|
||||
}
|
||||
|
||||
function onViewportPositionChanged(event) {
|
||||
@@ -856,16 +724,12 @@
|
||||
|
||||
if (event !== undefined) {
|
||||
if (event.recalculate === true) {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
return
|
||||
}
|
||||
}
|
||||
if (Math.random() * 100 > 95) {
|
||||
recalculateScaleX();
|
||||
recalculate();
|
||||
recalculateScaleY();
|
||||
};
|
||||
|
||||
} catch (err) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
setTimeFrame: setTimeFrame,
|
||||
setDatetime: setDatetime,
|
||||
draw: draw,
|
||||
recalculateScale: recalculateScale,
|
||||
|
||||
/* Events declared outside the plotter. */
|
||||
|
||||
@@ -111,8 +110,6 @@
|
||||
|
||||
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);
|
||||
@@ -133,7 +130,6 @@
|
||||
/* Ready for when dimmension changes. */
|
||||
|
||||
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
|
||||
recalculateScale()
|
||||
recalculate();
|
||||
})
|
||||
|
||||
@@ -444,37 +440,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScale -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
setTimeFrame: setTimeFrame,
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
recalculateScale: recalculateScale,
|
||||
draw: draw
|
||||
};
|
||||
|
||||
@@ -336,35 +335,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
if (fileSequence === undefined) { return; } // We need the market file to be loaded to make the calculation.
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] ' + MODULE_NAME + ' -> recalculateScale -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
plotChart();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
draw: draw,
|
||||
recalculateScale: recalculateScale,
|
||||
|
||||
/* Events declared outside the plotter. */
|
||||
|
||||
@@ -480,36 +479,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScale -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
draw: draw,
|
||||
recalculateScale: recalculateScale,
|
||||
|
||||
/* Events declared outside the plotter. */
|
||||
|
||||
@@ -461,36 +460,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScale -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
setDatetime: setDatetime,
|
||||
setCoordinateSystem: setCoordinateSystem,
|
||||
draw: draw,
|
||||
recalculateScale: recalculateScale,
|
||||
|
||||
/* Events declared outside the plotter. */
|
||||
|
||||
@@ -503,35 +502,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
try {
|
||||
|
||||
if (coordinateSystem.maxValue > 0) { return; } // Already calculated.
|
||||
|
||||
let minValue = {
|
||||
x: MIN_PLOTABLE_DATE.valueOf(),
|
||||
y: 0
|
||||
};
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
};
|
||||
|
||||
coordinateSystem.initialize(
|
||||
minValue,
|
||||
maxValue,
|
||||
thisObject.container.frame.width,
|
||||
thisObject.container.frame.height
|
||||
);
|
||||
|
||||
} catch (err) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] recalculateScale -> err = " + err.stack); }
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart() {
|
||||
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user