From 95364f52336936d65290f8d88d951a18d8199cd9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 14 Feb 2020 17:23:32 +0100 Subject: [PATCH] Giving Space for X Auto Scale --- ChartingSpace/CoordinateSystem.js | 30 +++++++++++++++--------------- Plotter.js | 4 ++-- Scales/AutoScaleButton.js | 8 ++++---- Scales/RateScale.js | 12 ++++++------ Spaces/DesignSpace.js | 6 +++++- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/ChartingSpace/CoordinateSystem.js b/ChartingSpace/CoordinateSystem.js index 9d2ce752c..6295c8529 100644 --- a/ChartingSpace/CoordinateSystem.js +++ b/ChartingSpace/CoordinateSystem.js @@ -15,10 +15,10 @@ function newCoordinateSystem () { maxWidth: undefined, scale: undefined, eventHandler: undefined, - autoMinScale: true, - autoMaxScale: true, + autoMinYScale: true, + autoMaxYScale: true, physics: physics, - reportValue: reportValue, + reportYValue: reportYValue, zoomX: zoomX, zoomY: zoomY, recalculateScale: recalculateScale, @@ -50,7 +50,7 @@ function newCoordinateSystem () { let newMax = -VERY_LARGE_NUMBER let newMin = VERY_LARGE_NUMBER - let notValueReported = true + let noYValueReported = true return thisObject @@ -74,25 +74,25 @@ function newCoordinateSystem () { } function physics () { - if ((thisObject.autoMinScale === true || thisObject.autoMaxScale === true) && notValueReported === false) { + if ((thisObject.autoMinYScale === true || thisObject.autoMaxYScale === true) && noYValueReported === false) { let mustRecalculate = false - if (thisObject.autoMaxScale === true && thisObject.max.y !== newMax) { + if (thisObject.autoMaxYScale === true && thisObject.max.y !== newMax) { thisObject.max.y = newMax mustRecalculate = true } - if (thisObject.autoMaxScale === true) { + if (thisObject.autoMaxYScale === true) { newMax = -VERY_LARGE_NUMBER } - if (thisObject.autoMinScale === true && thisObject.min.y !== newMin) { + if (thisObject.autoMinYScale === true && thisObject.min.y !== newMin) { thisObject.min.y = newMin newMin = VERY_LARGE_NUMBER mustRecalculate = true } - if (thisObject.autoMinScale === true) { + if (thisObject.autoMinYScale === true) { newMin = VERY_LARGE_NUMBER } @@ -102,18 +102,18 @@ function newCoordinateSystem () { /* Reseting this to start over at each cycle. */ - notValueReported = true + noYValueReported = true } } - function reportValue (value) { - if (thisObject.autoMinScale === true) { + function reportYValue (value) { + if (thisObject.autoMinYScale === true) { if (value < newMin) { newMin = value } - notValueReported = false + noYValueReported = false } - if (thisObject.autoMaxScale === true) { + if (thisObject.autoMaxYScale === true) { if (value > newMax) { newMax = value } - notValueReported = false + noYValueReported = false } } diff --git a/Plotter.js b/Plotter.js index 398d96b2b..e23e87dc3 100644 --- a/Plotter.js +++ b/Plotter.js @@ -569,7 +569,7 @@ function newPlotter () { y: y } /* Contributing to Auto-Scale */ - coordinateSystem.reportValue(dataPoint.y) + coordinateSystem.reportYValue(dataPoint.y) /* The information we store in files is independent from the charing system and its coordinate systems. @@ -769,7 +769,7 @@ function newPlotter () { } } - if (coordinateSystem.autoMinScale === true || coordinateSystem.autosMaxScale === true) { + if (coordinateSystem.autoMinYScale === true || coordinateSystem.autosMaxScale === true) { mustRecalculateDataPoints = true } else { mustRecalculateDataPoints = false diff --git a/Scales/AutoScaleButton.js b/Scales/AutoScaleButton.js index 465843d92..02cff0502 100644 --- a/Scales/AutoScaleButton.js +++ b/Scales/AutoScaleButton.js @@ -37,8 +37,8 @@ function newAutoScaleButton () { function initialize (pCoordinateSystem) { coordinateSystem = pCoordinateSystem - thisObject.autoMinScale = coordinateSystem.autoMinScale - thisObject.autoMaxScale = coordinateSystem.autoMaxScale + thisObject.autoMinScale = coordinateSystem.autoMinYScale + thisObject.autoMaxScale = coordinateSystem.autoMaxYScale thisObject.container.frame.width = 25 thisObject.container.frame.height = 25 @@ -81,8 +81,8 @@ function newAutoScaleButton () { } function update () { - coordinateSystem.autoMinScale = thisObject.autoMinScale - coordinateSystem.autoMaxScale = thisObject.autoMaxScale + coordinateSystem.autoMinYScale = thisObject.autoMinScale + coordinateSystem.autoMaxYScale = thisObject.autoMaxScale coordinateSystem.recalculateScale() } } diff --git a/Scales/RateScale.js b/Scales/RateScale.js index f549fc85f..e1a9651ec 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -169,8 +169,8 @@ function newRateScale () { let code = JSON.parse(thisObject.payload.node.code) code.minValue = coordinateSystem.min.y code.maxValue = coordinateSystem.max.y - code.autoMinScale = coordinateSystem.autoMinScale - code.autoMaxScale = coordinateSystem.autoMaxScale + code.autoMinScale = coordinateSystem.autoMinYScale + code.autoMaxScale = coordinateSystem.autoMaxYScale thisObject.payload.node.code = JSON.stringify(code, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. @@ -190,8 +190,8 @@ function newRateScale () { if ( thisObject.minValue !== code.minValue || thisObject.maxValue !== code.maxValue || - coordinateSystem.autoMinScale !== code.autoMinScale || - coordinateSystem.autoMaxScale !== code.autoMaxScale + coordinateSystem.autoMinYScale !== code.autoMinScale || + coordinateSystem.autoMaxYScale !== code.autoMaxScale ) { thisObject.minValue = code.minValue thisObject.maxValue = code.maxValue @@ -199,11 +199,11 @@ function newRateScale () { coordinateSystem.max.y = thisObject.maxValue if (code.autoMinScale !== undefined && (code.autoMinScale === true || code.autoMinScale === false)) { - coordinateSystem.autoMinScale = code.autoMinScale + coordinateSystem.autoMinYScale = code.autoMinScale autoScaleButton.autoMinScale = code.autoMinScale } if (code.autoMaxScale !== undefined && (code.autoMaxScale === true || code.autoMaxScale === false)) { - coordinateSystem.autoMaxScale = code.autoMaxScale + coordinateSystem.autoMaxYScale = code.autoMaxScale autoScaleButton.autoMaxScale = code.autoMaxScale } coordinateSystem.recalculateScale() diff --git a/Spaces/DesignSpace.js b/Spaces/DesignSpace.js index f18183387..c2cba9767 100644 --- a/Spaces/DesignSpace.js +++ b/Spaces/DesignSpace.js @@ -247,7 +247,11 @@ function newDesignSpace () { 'toggle-auto-scale-auto-min-max', 'toggle-auto-scale-auto-max', 'toggle-auto-scale-auto-min', - 'toggle-panel-off' + 'toggle-panel-off', + 'toggle-auto-time-scale-auto-min', + 'toggle-auto-time-scale-auto-max', + 'toggle-auto-time-scale-auto-min-max', + 'toggle-auto-time-scale-manual' ] for (let i = 0; i < iconsNames.length; i++) {