From 0d70f64c5693e1a7923cf2e28f8d0a008840a507 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 19:13:25 +0100 Subject: [PATCH] Scales do not leave visible area --- ChartsSpace/TimeMachine.js | 10 +++++----- ChartsSpace/TimelineChart.js | 6 +++--- Spaces/ChartSpace.js | 12 +++++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 032e57669..bc96d5c07 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -301,30 +301,30 @@ function newTimeMachine () { /* timeScale Positioning */ - thisObject.timeScale.container.frame.position.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 - timePoint = { x: 0, y: 0 } timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) + timePoint.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2 timePoint = thisObject.container.fitFunction(timePoint) + thisObject.timeScale.container.frame.position.x = timePoint.x thisObject.timeScale.container.frame.position.y = timePoint.y /* rateScale Positioning */ - thisObject.rateScale.container.frame.position.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 - ratePoint = { x: thisObject.container.frame.width, y: 0 } ratePoint = transformThisPoint(ratePoint, thisObject.container.frame.container) - ratePoint = thisObject.container.fitFunction(ratePoint) + ratePoint.y = mouse.position.y - thisObject.rateScale.container.frame.height / 2 + thisObject.rateScale.container.frame.height + ratePoint = thisObject.container.fitFunction(ratePoint, true) + thisObject.rateScale.container.frame.position.y = ratePoint.y - thisObject.rateScale.container.frame.height thisObject.rateScale.container.frame.position.x = ratePoint.x - thisObject.rateScale.container.frame.width } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 9ee435e4c..21cb8b82e 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -279,16 +279,16 @@ function newTimelineChart () { /* thisObject.timeFrameScale Positioning */ - thisObject.timeFrameScale.container.frame.position.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 - timePoint = { x: 0, y: thisObject.container.frame.height } timePoint = transformThisPoint(timePoint, thisObject.container.frame.container) - timePoint = thisObject.container.fitFunction(timePoint) + timePoint.x = mouse.position.x - thisObject.timeFrameScale.container.frame.width / 2 + timePoint = thisObject.container.fitFunction(timePoint, true) + thisObject.timeFrameScale.container.frame.position.x = timePoint.x thisObject.timeFrameScale.container.frame.position.y = timePoint.y - thisObject.timeFrameScale.container.frame.height } diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 5f9932fa3..2879666d3 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -138,7 +138,7 @@ function newChartSpace () { viewPort.displace(displaceVector, true) } - function fitIntoVisibleArea (point) { + function fitIntoVisibleArea (point, fullVisible) { /* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */ let returnPoint = { @@ -154,8 +154,14 @@ function newChartSpace () { returnPoint.x = 0 } - if (point.y > COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2) { - returnPoint.y = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2 + if (fullVisible === true) { + if (point.y > COCKPIT_SPACE_POSITION) { + returnPoint.y = COCKPIT_SPACE_POSITION + } + } else { + if (point.y > COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2) { + returnPoint.y = COCKPIT_SPACE_POSITION + COCKPIT_SPACE_HEIGHT / 2 + } } if (point.y < 0) {