Chart Aspect Ratio Button and functionality eliminated

This commit is contained in:
Luis Fernando Molina committed 2019-04-11 12:12:41 +02:00
1 parent f0b8c8dbc6
commit b3d17813df
7 files changed
+2 -170

No files matched your search

-115
View File
@@ -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)
}
}
-30
View File
@@ -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.') }
+1 -1
View File
@@ -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 = {
-10
View File
@@ -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 () {
-6
View File
@@ -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
+1 -1
View File
@@ -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
-7
View File
@@ -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)