changes in ratescale working

This commit is contained in:
Luis Fernando Molina committed 2020-01-30 23:28:40 +01:00
1 parent 4b5613db1f
commit 1e4238ea3c
4 files changed
+40 -90

No files matched your search

+14 -60
View File
@@ -188,76 +188,30 @@ function getUserPosition (coordinateSystem) {
return userPosition
}
function moveToUserPosition (container, coordinateSystem, ignoreX, ignoreY, center, moveContainer) {
let userPosition = getUserPosition(coordinateSystem)
INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom)
NEW_SESSION_INITIAL_DATE = new Date(userPosition.date)
function moveToUserPosition (container, currentDate, currentRate, coordinateSystem, ignoreX, ignoreY, mousePosition) {
let targetPoint = {
x: (new Date(userPosition.date)).valueOf(),
y: userPosition.rate
x: currentDate.valueOf(),
y: currentRate
}
/* Put this po int in the coordinate system of the canvas.chartSpace.viewport */
/* Put this point in the coordinate system of the canvas.chartSpace.viewport */
targetPoint = coordinateSystem.transformThisPoint(targetPoint)
targetPoint = transformThisPoint(targetPoint, container)
let centerPoint
if (center !== undefined) {
centerPoint = {
x: center.x,
y: center.y
}
} else {
centerPoint = {
x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2,
y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 2
}
}
/* When we are moving the container, it needs to consider the zooming of the viewport */
/* Lets calculate the displace vector, from the point we want at the center, to the current center. */
let displaceVector
if (moveContainer === true) {
let targetCopy = {
x: targetPoint.x,
y: targetPoint.y
}
let targetNoZoom
targetNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(targetCopy)
let targetNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(targetPoint)
let mouseNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(mousePosition)
let centerCopy = {
x: centerPoint.x,
y: centerPoint.y
}
let centerNoZoom
centerNoZoom = canvas.chartSpace.viewport.unTransformThisPoint(centerCopy)
displaceVector = {
x: centerNoZoom.x - targetNoZoom.x,
y: centerNoZoom.y - targetNoZoom.y
}
if (ignoreX) { displaceVector.x = 0 }
if (ignoreY) { displaceVector.y = 0 }
container.displace(displaceVector)
} else {
displaceVector = {
x: centerPoint.x - targetPoint.x,
y: centerPoint.y - targetPoint.y
}
if (ignoreX) { displaceVector.x = 0 }
if (ignoreY) { displaceVector.y = 0 }
canvas.chartSpace.viewport.displace(displaceVector)
displaceVector = {
x: mouseNoZoom.x - targetNoZoom.x,
y: mouseNoZoom.y - targetNoZoom.y
}
if (ignoreX) { displaceVector.x = 0 }
if (ignoreY) { displaceVector.y = 0 }
container.displace(displaceVector)
}
function removeTime (datetime) {