TimeScale acepting from and to in scale configuration
This commit is contained in:
1 parent
d829472638
commit
ded51e5381
3 files changed
+47
-28
No files matched your search
@@ -601,12 +601,12 @@ function newTimeMachine () {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4
|
||||
}
|
||||
/*
|
||||
|
||||
if (thisObject.timeScale !== undefined) {
|
||||
minValue.y = thisObject.rateScale.minValue
|
||||
maxValue.y = thisObject.rateScale.maxValue
|
||||
minValue.x = thisObject.timeScale.fromDate
|
||||
maxValue.x = thisObject.timeScale.toDate
|
||||
}
|
||||
*/
|
||||
|
||||
if (thisObject.rateScale !== undefined) {
|
||||
minValue.y = thisObject.rateScale.minValue
|
||||
maxValue.y = thisObject.rateScale.maxValue
|
||||
|
||||
+3
-3
@@ -218,7 +218,7 @@ function newRateScale () {
|
||||
code.offset = thisObject.offset
|
||||
code.minValue = thisObject.minValue
|
||||
code.maxValue = thisObject.maxValue
|
||||
thisObject.payload.node.code = JSON.stringify(code)
|
||||
thisObject.payload.node.code = JSON.stringify(code, null, 4)
|
||||
} catch (err) {
|
||||
// we ignore errors here since most likely they will be parsing errors.
|
||||
}
|
||||
@@ -279,8 +279,8 @@ function newRateScale () {
|
||||
} else {
|
||||
thisObject.minValue = code.minValue
|
||||
thisObject.maxValue = code.maxValue
|
||||
coordinateSystem.min.y = code.minValue
|
||||
coordinateSystem.max.y = code.maxValue
|
||||
coordinateSystem.min.y = thisObject.minValue
|
||||
coordinateSystem.max.y = thisObject.maxValue
|
||||
coordinateSystem.recalculateScale()
|
||||
}
|
||||
saveObjectState() // this overrides any invalid value at the config.
|
||||
|
||||
+40
-21
@@ -8,6 +8,8 @@ function newTimeScale () {
|
||||
fitFunction: undefined,
|
||||
payload: undefined,
|
||||
isVisible: true,
|
||||
fromDate: undefined,
|
||||
toDate: undefined,
|
||||
onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
@@ -72,6 +74,9 @@ function newTimeScale () {
|
||||
coordinateSystem = pCoordinateSystem
|
||||
limitingContainer = pLimitingContainer
|
||||
|
||||
thisObject.fromDate = coordinateSystem.min.x
|
||||
thisObject.toDate = coordinateSystem.max.x
|
||||
|
||||
onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
|
||||
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
@@ -155,7 +160,9 @@ function newTimeScale () {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
code.scale = thisObject.scale / MAX_SCALE * 100
|
||||
code.scale = code.scale.toFixed(0)
|
||||
thisObject.payload.node.code = JSON.stringify(code)
|
||||
code.fromDate = (new Date(thisObject.fromDate)).toISOString()
|
||||
code.toDate = (new Date(thisObject.toDate)).toISOString()
|
||||
thisObject.payload.node.code = JSON.stringify(code, null, 4)
|
||||
} catch (err) {
|
||||
// we ignore errors here since most likely they will be parsing errors.
|
||||
}
|
||||
@@ -166,28 +173,40 @@ function newTimeScale () {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
|
||||
if (isNaN(code.scale) || code.scale === null || code.scale === undefined) {
|
||||
saveObjectState()
|
||||
return
|
||||
}
|
||||
code.scale = code.scale / 100 * MAX_SCALE
|
||||
if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE }
|
||||
if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE }
|
||||
|
||||
if (code.scale !== thisObject.scale) {
|
||||
thisObject.scale = code.scale
|
||||
let event = {}
|
||||
if (
|
||||
thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE &&
|
||||
thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE
|
||||
) {
|
||||
event.scale = DEFAULT_SCALE
|
||||
} else {
|
||||
event.scale = thisObject.scale
|
||||
}
|
||||
thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event)
|
||||
// not using this value
|
||||
} else {
|
||||
saveObjectState()
|
||||
code.scale = code.scale / 100 * MAX_SCALE
|
||||
if (code.scale < MIN_SCALE) { code.scale = MIN_SCALE }
|
||||
if (code.scale > MAX_SCALE) { code.scale = MAX_SCALE }
|
||||
|
||||
if (code.scale !== thisObject.scale) {
|
||||
thisObject.scale = code.scale
|
||||
let event = {}
|
||||
if (
|
||||
thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE &&
|
||||
thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE
|
||||
) {
|
||||
event.scale = DEFAULT_SCALE
|
||||
} else {
|
||||
event.scale = thisObject.scale
|
||||
}
|
||||
thisObject.container.eventHandler.raiseEvent('Time Scale Value Changed', event)
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(isNaN(Date.parse(code.fromDate)) || code.fromDate === null || code.fromDate === undefined) ||
|
||||
(isNaN(Date.parse(code.toDate)) || code.toDate === null || code.toDate === undefined)
|
||||
) {
|
||||
// not using this value
|
||||
} else {
|
||||
thisObject.fromDate = Date.parse(code.fromDate)
|
||||
thisObject.toDate = Date.parse(code.toDate)
|
||||
coordinateSystem.min.x = thisObject.fromDate
|
||||
coordinateSystem.max.x = thisObject.toDate
|
||||
coordinateSystem.recalculateScale()
|
||||
}
|
||||
saveObjectState() // this overrides any invalid value at the config.
|
||||
} catch (err) {
|
||||
// we ignore errors here since most likely they will be parsing errors.
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user