From b3d17813df723caca765714d689ca8fe24a8b6e5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 11 Apr 2019 12:12:41 +0200 Subject: [PATCH] Chart Aspect Ratio Button and functionality eliminated --- BottomSpace/ChartAspectRatio.js | 115 -------------------------------- PlottersManager.js | 30 --------- Scales/ChartGrid.js | 2 +- Spaces/BottomSpace.js | 10 --- Spaces/ChartSpace.js | 6 -- TimeMachine.js | 2 +- TimelineChart.js | 7 -- 7 files changed, 2 insertions(+), 170 deletions(-) delete mode 100644 BottomSpace/ChartAspectRatio.js diff --git a/BottomSpace/ChartAspectRatio.js b/BottomSpace/ChartAspectRatio.js deleted file mode 100644 index 599fb97d2..000000000 --- a/BottomSpace/ChartAspectRatio.js +++ /dev/null @@ -1,115 +0,0 @@ - function newChartAspectRatio () { - let thisObject = { - aspectRatio: undefined, - draw: draw, - getContainer: getContainer, - initialize: initialize - } - - let container = newContainer() - container.initialize() - thisObject.container = container - - thisObject.container.frame.width = 50 - thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT - - resize() - - container.isDraggeable = false - container.isClickeable = false - container.isWheelable = true - - thisObject.aspectRatio = {} - - const INITIAL_Y_ASPECT_RATIO = 5 / 10 - const MIN_Y_ASPECT_RATIO = 1 / 10 - const MAX_Y_ASPECT_RATIO = 10 / 10 - - thisObject.aspectRatio.x = 1 - thisObject.aspectRatio.y = INITIAL_Y_ASPECT_RATIO - - canDrawIcon = false - - return thisObject - - function initialize () { - icon = new Image() - - icon.onload = onImageLoad - - function onImageLoad () { - canDrawIcon = true - } - - icon.src = window.canvasApp.urlPrefix + 'Images/Icons/chart-scale.png' - - thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel) - - window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) - } - - function resize () { - container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width - container.frame.position.y = viewPort.visibleArea.bottomLeft.y - } - - function onMouseWheel (event) { - delta = event.wheelDelta - - if (viewPort.isMinZoom() === false) { return } // We only make this button to work at the min zoom level. - - if (delta < 0) { - delta = -0.1 - } else { - delta = 0.1 - } - - thisObject.aspectRatio.y = thisObject.aspectRatio.y + delta - thisObject.aspectRatio.y = Math.round(thisObject.aspectRatio.y * 100) / 100 - - if (thisObject.aspectRatio.y < MIN_Y_ASPECT_RATIO) { - thisObject.aspectRatio.y = MIN_Y_ASPECT_RATIO - } - - if (thisObject.aspectRatio.y > MAX_Y_ASPECT_RATIO) { - thisObject.aspectRatio.y = MAX_Y_ASPECT_RATIO - } - - thisObject.container.eventHandler.raiseEvent('Chart Aspect Ratio Changed', thisObject.aspectRatio) - } - - function getContainer (point) { - let container - - /* First we check if this point is inside this object UI. */ - - if (thisObject.container.frame.isThisPointHere(point, true) === true) { - return this.container - } else { - /* This point does not belong to this space. */ - - return undefined - } - } - - function draw () { - thisObject.container.frame.draw(false, false) - - if (canDrawIcon === false) { return } - if (viewPort.isMinZoom() === false) { return } // We only show this button at the min zoom level. - - let breakpointsHeight = 15 - - let imageHeight = 15 - let imageWidth = 15 - - let imagePoint = { - x: 10, - y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight - } - - imagePoint = thisObject.container.frame.frameThisPoint(imagePoint) - - browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight) - } - } diff --git a/PlottersManager.js b/PlottersManager.js index bb4760a88..b73fbc704 100644 --- a/PlottersManager.js +++ b/PlottersManager.js @@ -111,36 +111,6 @@ function newPlottersManager () { initializeCompetitionPlotters(onCompetitionPlottersInitialized) - canvas.bottomSpace.chartAspectRatio.container.eventHandler.listenToEvent('Chart Aspect Ratio Changed', onAspectRatioChanged) - - function onAspectRatioChanged (pAspectRatio) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * pAspectRatio.y - - /* First the Product Plotters. */ - - for (let i = 0; i < productPlotters.length; i++) { - let productPlotter = productPlotters[i] - productPlotter.plotter.container.frame.width = thisObject.container.frame.width - productPlotter.plotter.container.frame.height = thisObject.container.frame.height - - if (productPlotter.plotter.recalculateScale !== undefined) { - productPlotter.plotter.recalculateScale() - } - } - - /* Then the competition plotters. */ - - for (let i = 0; i < competitionPlotters.length; i++) { - let competitionPlotter = competitionPlotters[i] - competitionPlotter.plotter.container.frame.width = thisObject.container.frame.width - competitionPlotter.plotter.container.frame.height = thisObject.container.frame.height - - if (competitionPlotter.plotter.recalculateScale !== undefined) { - competitionPlotter.plotter.recalculateScale() - } - } - } - function onCompetitionPlottersInitialized (err) { try { if (INFO_LOG === true) { logger.write('[INFO] initialize -> onCompetitionPlottersInitialized -> Entering function.') } diff --git a/Scales/ChartGrid.js b/Scales/ChartGrid.js index 86aa268ee..3ceb3bd35 100644 --- a/Scales/ChartGrid.js +++ b/Scales/ChartGrid.js @@ -55,7 +55,7 @@ const basePeriod = { x: 8 * 60 * 60 * 1000, - y: timeLineCoordinateSystem.max.y / 1000 / canvas.bottomSpace.chartAspectRatio.aspectRatio.y + y: timeLineCoordinateSystem.max.y / 1000 } let period = { diff --git a/Spaces/BottomSpace.js b/Spaces/BottomSpace.js index 6a206873c..9121a5356 100644 --- a/Spaces/BottomSpace.js +++ b/Spaces/BottomSpace.js @@ -2,7 +2,6 @@ function newBottomSpace () { var thisObject = { deleteTradingHistory: undefined, - chartAspectRatio: undefined, container: undefined, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. @@ -23,9 +22,6 @@ function newBottomSpace () { thisObject.deleteTradingHistory = newDeleteTradingHistory() thisObject.deleteTradingHistory.initialize() - thisObject.chartAspectRatio = newChartAspectRatio() - thisObject.chartAspectRatio.initialize() - window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize) } @@ -43,11 +39,6 @@ function newBottomSpace () { container = thisObject.deleteTradingHistory.getContainer(point) if (container !== undefined) { return container } - container = thisObject.chartAspectRatio.getContainer(point) - if (container !== undefined) { return container } - - /* The point does not belong to any inner container, so we return the current container. */ - return thisObject.container } @@ -56,7 +47,6 @@ function newBottomSpace () { drawBackground() thisObject.deleteTradingHistory.draw() - thisObject.chartAspectRatio.draw() } function drawBackground () { diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 2486cb0a7..80b0c838e 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -25,13 +25,7 @@ function newChartSpace () { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) -/* - thisObject.container.frame.width = TIME_MACHINE_WIDTH - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * canvas.bottomSpace.chartAspectRatio.aspectRatio.y - thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2 - thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2 -*/ thisObject.container.isDraggeable = false return thisObject diff --git a/TimeMachine.js b/TimeMachine.js index 1dcbaf300..75e11f84a 100644 --- a/TimeMachine.js +++ b/TimeMachine.js @@ -31,7 +31,7 @@ function newTimeMachine () { thisObject.container.detectMouseOver = true thisObject.container.frame.width = TIME_MACHINE_WIDTH - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * canvas.bottomSpace.chartAspectRatio.aspectRatio.y + thisObject.container.frame.height = TIME_MACHINE_HEIGHT thisObject.container.frame.position.x = browserCanvas.width / 2 - TIME_MACHINE_WIDTH / 2 thisObject.container.frame.position.y = browserCanvas.height / 2 - TIME_MACHINE_HEIGHT / 2 diff --git a/TimelineChart.js b/TimelineChart.js index de2ed5f5f..da21b21be 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -159,13 +159,6 @@ callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) return } - - canvas.bottomSpace.chartAspectRatio.container.eventHandler.listenToEvent('Chart Aspect Ratio Changed', onAspectRatioChanged) - - function onAspectRatioChanged (pAspectRatio) { - thisObject.container.frame.height = TIME_MACHINE_HEIGHT * pAspectRatio.y - recalculateScale() - } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)