diff --git a/.vs/Plotters-Candles-Volumes/v15/.suo b/.vs/Plotters-Candles-Volumes/v15/.suo index 51998f4f1..e5084feca 100644 Binary files a/.vs/Plotters-Candles-Volumes/v15/.suo and b/.vs/Plotters-Candles-Volumes/v15/.suo differ diff --git a/Candles.js b/Candles.js index 5e8cb0d86..8c03872e7 100644 --- a/Candles.js +++ b/Candles.js @@ -23,7 +23,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. @@ -55,7 +55,6 @@ marketFile = fileCache.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster. recalculateScale(); - recalculate(); /* Now we set the right files according to current Period. */ @@ -67,6 +66,10 @@ viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged); canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); + /* Get ready for plotting. */ + + recalculate(); + callBackFunction(); } @@ -167,7 +170,7 @@ y: candles[i].open }; - targetPoint = plotArea.inverseTransform(targetPoint, thisObject.container.frame.height); + targetPoint = timeLineCoordinateSystem.inverseTransform(targetPoint, thisObject.container.frame.height); targetPoint = transformThisPoint(targetPoint, thisObject.container); let targetMax = { @@ -175,7 +178,7 @@ y: candles[i].max }; - targetMax = plotArea.inverseTransform(targetMax, thisObject.container.frame.height); + targetMax = timeLineCoordinateSystem.inverseTransform(targetMax, thisObject.container.frame.height); targetMax = transformThisPoint(targetMax, thisObject.container); let targetMin = { @@ -183,7 +186,7 @@ y: candles[i].min }; - targetMin = plotArea.inverseTransform(targetMin, thisObject.container.frame.height); + targetMin = timeLineCoordinateSystem.inverseTransform(targetMin, thisObject.container.frame.height); targetMin = transformThisPoint(targetMin, thisObject.container); let center = { @@ -254,8 +257,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(); @@ -342,8 +345,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(); @@ -397,7 +400,7 @@ if (marketFile === 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(), @@ -410,7 +413,7 @@ }; - plotArea.initialize( + timeLineCoordinateSystem.initialize( minValue, maxValue, thisObject.container.frame.width, @@ -466,10 +469,10 @@ y: candle.close }; - candlePoint1 = plotArea.inverseTransform(candlePoint1, thisObject.container.frame.height); - candlePoint2 = plotArea.inverseTransform(candlePoint2, thisObject.container.frame.height); - candlePoint3 = plotArea.inverseTransform(candlePoint3, thisObject.container.frame.height); - candlePoint4 = plotArea.inverseTransform(candlePoint4, thisObject.container.frame.height); + candlePoint1 = timeLineCoordinateSystem.inverseTransform(candlePoint1, thisObject.container.frame.height); + candlePoint2 = timeLineCoordinateSystem.inverseTransform(candlePoint2, thisObject.container.frame.height); + candlePoint3 = timeLineCoordinateSystem.inverseTransform(candlePoint3, thisObject.container.frame.height); + candlePoint4 = timeLineCoordinateSystem.inverseTransform(candlePoint4, thisObject.container.frame.height); candlePoint1 = transformThisPoint(candlePoint1, thisObject.container); candlePoint2 = transformThisPoint(candlePoint2, thisObject.container); @@ -505,10 +508,10 @@ y: candle.min }; - stickPoint1 = plotArea.inverseTransform(stickPoint1, thisObject.container.frame.height); - stickPoint2 = plotArea.inverseTransform(stickPoint2, thisObject.container.frame.height); - stickPoint3 = plotArea.inverseTransform(stickPoint3, thisObject.container.frame.height); - stickPoint4 = plotArea.inverseTransform(stickPoint4, thisObject.container.frame.height); + stickPoint1 = timeLineCoordinateSystem.inverseTransform(stickPoint1, thisObject.container.frame.height); + stickPoint2 = timeLineCoordinateSystem.inverseTransform(stickPoint2, thisObject.container.frame.height); + stickPoint3 = timeLineCoordinateSystem.inverseTransform(stickPoint3, thisObject.container.frame.height); + stickPoint4 = timeLineCoordinateSystem.inverseTransform(stickPoint4, thisObject.container.frame.height); stickPoint1 = transformThisPoint(stickPoint1, thisObject.container); stickPoint2 = transformThisPoint(stickPoint2, thisObject.container); diff --git a/Volumes.js b/Volumes.js index ad1520b2c..4561bcda1 100644 --- a/Volumes.js +++ b/Volumes.js @@ -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 plotAreaFrame = 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. @@ -52,10 +52,6 @@ scaleFile = fileCache.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster. - recalculateScaleX(); - recalculate(); - recalculateScaleY(); - /* Now we set the right files according to current Period. */ marketFile = fileCache.getFile(pTimePeriod); @@ -66,6 +62,12 @@ viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged); canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished); + /* Get ready for plotting. */ + + recalculateScaleX(); + recalculate(); + recalculateScaleY(); + callBackFunction(); } @@ -193,8 +195,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(); @@ -270,8 +272,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(); @@ -321,7 +323,7 @@ x: MAX_PLOTABLE_DATE.valueOf() }; - plotArea.initializeX( + timeLineCoordinateSystem.initializeX( minValue, maxValue, thisObject.container.frame.width @@ -349,7 +351,7 @@ maxValue.y = getMaxVolume() / (timePeriodRatio / 10); - plotArea.initializeY( + timeLineCoordinateSystem.initializeY( minValue, maxValue, viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y @@ -466,13 +468,13 @@ 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; } @@ -520,13 +522,13 @@ 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; }