plotArea refactored Part 1

This commit is contained in:
Luis Fernando Molina committed 2018-03-03 12:10:14 +01:00
1 parent e64330749d
commit 62a3e83915
3 files changed
+22 -22

No files matched your search

Binary file not shown.
+18 -18
View File
@@ -18,8 +18,8 @@
container.initialize();
thisObject.container = container;
let plotArea = newPlotArea(); // Needed to be able to plot on the timeline, otherwise not.
let plotAreaFrame = newPlotArea(); // This chart uses this extra object.
let timeLineCoordinateSystem = newTimeLineCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let timeLineCoordinateSystemFrame = newTimeLineCoordinateSystem(); // This chart uses this extra object.
let timePeriod; // This will hold the current Time Period the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -230,8 +230,8 @@
let daysOnSides = getSideDays(timePeriod);
let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, plotArea);
let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, plotArea);
let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem);
let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem);
let dateDiff = rightDate.valueOf() - leftDate.valueOf();
@@ -307,8 +307,8 @@
let daysOnSides = getSideDays(timePeriod);
let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, plotArea);
let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, plotArea);
let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem);
let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem);
let dateDiff = rightDate.valueOf() - leftDate.valueOf();
@@ -358,13 +358,13 @@
x: MAX_PLOTABLE_DATE.valueOf()
};
plotArea.initializeX(
timeLineCoordinateSystem.initializeX(
minValue,
maxValue,
thisObject.container.frame.width
);
plotAreaFrame.initializeX(
timeLineCoordinateSystemFrame.initializeX(
minValue,
maxValue,
thisObject.container.frame.width
@@ -386,13 +386,13 @@
maxValue.y = getMaxVolume() / (timePeriodRatio / 10);
plotArea.initializeY(
timeLineCoordinateSystem.initializeY(
minValue,
maxValue,
viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y
);
plotAreaFrame.initializeY(
timeLineCoordinateSystemFrame.initializeY(
minValue,
maxValue,
thisObject.container.frame.height
@@ -499,17 +499,17 @@
}
if (calculateBuys(plotAreaFrame, thisObject.container.frame.height) === false) { continue; } // We try to see if it fits in the visible area.
if (calculateBuys(timeLineCoordinateSystemFrame, thisObject.container.frame.height) === false) { continue; } // We try to see if it fits in the visible area.
if (volumePointA1.y > viewPort.visibleArea.bottomLeft.y && frameHeightInViewPort > visibleHeight * 2 / 3) {
if (calculateBuys(plotArea, visibleHeight) === false) { continue; } // We snap t to the view port.
if (calculateBuys(timeLineCoordinateSystem, visibleHeight) === false) { continue; } // We snap t to the view port.
/* Now we set the real value of y. */
volumePointA1.y = viewPort.visibleArea.bottomRight.y;
volumePointA2.y = viewPort.visibleArea.bottomRight.y - volume.amountBuy * plotArea.scale.y;
volumePointA3.y = viewPort.visibleArea.bottomRight.y - volume.amountBuy * plotArea.scale.y;
volumePointA2.y = viewPort.visibleArea.bottomRight.y - volume.amountBuy * timeLineCoordinateSystem.scale.y;
volumePointA3.y = viewPort.visibleArea.bottomRight.y - volume.amountBuy * timeLineCoordinateSystem.scale.y;
volumePointA4.y = viewPort.visibleArea.bottomRight.y;
}
@@ -553,17 +553,17 @@
}
calculateSells(plotAreaFrame, thisObject.container.frame.height); // We try to see if it fits in the visible area.
calculateSells(timeLineCoordinateSystemFrame, thisObject.container.frame.height); // We try to see if it fits in the visible area.
if (volumePointB1.y < viewPort.visibleArea.topLeft.y && frameHeightInViewPort > visibleHeight * 2 / 3) {
calculateSells(plotArea, visibleHeight); // We snap it to the view port.
calculateSells(timeLineCoordinateSystem, visibleHeight); // We snap it to the view port.
/* Now we set the real value of y. */
volumePointB1.y = viewPort.visibleArea.topLeft.y;
volumePointB2.y = viewPort.visibleArea.topLeft.y + volume.amountSell * plotArea.scale.y;
volumePointB3.y = viewPort.visibleArea.topLeft.y + volume.amountSell * plotArea.scale.y;
volumePointB2.y = viewPort.visibleArea.topLeft.y + volume.amountSell * timeLineCoordinateSystem.scale.y;
volumePointB3.y = viewPort.visibleArea.topLeft.y + volume.amountSell * timeLineCoordinateSystem.scale.y;
volumePointB4.y = viewPort.visibleArea.topLeft.y;
}
+4 -4
View File
@@ -18,7 +18,7 @@
container.initialize();
thisObject.container = container;
let plotArea = newPlotArea(); // Needed to be able to plot on the timeline, otherwise not.
let timeLineCoordinateSystem = newTimeLineCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let timePeriod; // This will hold the current Time Period the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -119,7 +119,7 @@
if (file === undefined) { return; } // We need the market file to be loaded to make the calculation.
if (plotArea.maxValue > 0) { return; } // Already calculated.
if (timeLineCoordinateSystem.maxValue > 0) { return; } // Already calculated.
let minValue = {
x: EARLIEST_DATE.valueOf(),
@@ -132,7 +132,7 @@
};
plotArea.initialize(
timeLineCoordinateSystem.initialize(
minValue,
maxValue,
thisObject.container.frame.width,
@@ -169,7 +169,7 @@
y: record.rate
};
point = plotArea.inverseTransform(point, thisObject.container.frame.height);
point = timeLineCoordinateSystem.inverseTransform(point, thisObject.container.frame.height);
point = transformThisPoint(point, thisObject.container);