min and max value of rate scales
This commit is contained in:
1 parent
05debc3b55
commit
ca6463c264
10 files changed
+62
-46
No files matched your search
@@ -526,7 +526,7 @@ function newTimeMachine () {
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(USDT_BTC_HTH) / 4
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4
|
||||
}
|
||||
|
||||
timeMachineCoordinateSystem.initialize(
|
||||
|
||||
@@ -455,7 +455,7 @@ function newTimelineChart () {
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(USDT_BTC_HTH) / 4
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4
|
||||
}
|
||||
|
||||
timelineChartCoordinateSystem.initialize(
|
||||
|
||||
@@ -135,11 +135,11 @@ function newViewport () {
|
||||
|
||||
function physics () {
|
||||
animationPhysics()
|
||||
positioningphysics()
|
||||
positioningPhysics()
|
||||
readObjectState()
|
||||
}
|
||||
|
||||
function positioningphysics () {
|
||||
function positioningPhysics () {
|
||||
if (thisObject.payload === undefined) { return }
|
||||
/* Save the position at the frame lavel */
|
||||
let frame = {}
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ const DEFAULT_CONFIG_TEXT = '// Write your config here'
|
||||
const DEFAULT_FORMULA_TEXT = '// Write your formula here'
|
||||
const DEFAULT_CODE_TEXT = '// Write your code here'
|
||||
|
||||
const USDT_BTC_HTH = 19900; // This is needed to know the scale of the market time line.
|
||||
const MAX_DEFAULT_RATE_SCALE_VALUE = 19900; // This is needed to know the scale of the market time line.
|
||||
|
||||
const WIDHTER_VOLUME_BAR_BASE_FACTOR = 2.5;
|
||||
const LESS_WIDHTER_VOLUME_BAR_TOP_FACTOR = 1 / 4;
|
||||
|
||||
+1
-1
@@ -450,7 +450,7 @@ function newPlotter () {
|
||||
|
||||
let maxValue = {
|
||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||
y: nextPorwerOf10(USDT_BTC_HTH) / 4 // TODO: This 4 is temporary
|
||||
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary
|
||||
}
|
||||
|
||||
coordinateSystem.initialize(
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@
|
||||
<Compile Include="Frame.js" />
|
||||
<Compile Include="Panels\LayersPanel.js" />
|
||||
<Compile Include="Panels\TimeControlPanel.js" />
|
||||
<Compile Include="TimeLineCoordinateSystem.js" />
|
||||
<Compile Include="coordinateSystem.js" />
|
||||
<Compile Include="SplashScreen.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
+29
-13
@@ -8,6 +8,8 @@ function newRateScale () {
|
||||
payload: undefined,
|
||||
scale: undefined,
|
||||
offset: undefined,
|
||||
minValue: undefined,
|
||||
maxValue: undefined,
|
||||
setScale: setScale,
|
||||
onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer,
|
||||
physics: physics,
|
||||
@@ -50,7 +52,7 @@ function newRateScale () {
|
||||
let onMouseOverEventSubscriptionId
|
||||
let onMouseNotOverEventSubscriptionId
|
||||
|
||||
let timeLineCoordinateSystem
|
||||
let coordinateSystem
|
||||
let limitingContainer
|
||||
let rateCalculationsContainer
|
||||
|
||||
@@ -75,14 +77,14 @@ function newRateScale () {
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.payload = undefined
|
||||
|
||||
timeLineCoordinateSystem = undefined
|
||||
coordinateSystem = undefined
|
||||
limitingContainer = undefined
|
||||
rateCalculationsContainer = undefined
|
||||
mouse = undefined
|
||||
}
|
||||
|
||||
function initialize (pTimeLineCoordinateSystem, pLimitingContainer, pRateCalculationsContainer) {
|
||||
timeLineCoordinateSystem = pTimeLineCoordinateSystem
|
||||
function initialize (pCoordinateSystem, pLimitingContainer, pRateCalculationsContainer) {
|
||||
coordinateSystem = pCoordinateSystem
|
||||
limitingContainer = pLimitingContainer
|
||||
rateCalculationsContainer = pRateCalculationsContainer
|
||||
|
||||
@@ -233,10 +235,7 @@ function newRateScale () {
|
||||
saveObjectState()
|
||||
return
|
||||
}
|
||||
if (isNaN(code.offset) || code.offset === null || code.offset === 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 }
|
||||
@@ -258,6 +257,11 @@ function newRateScale () {
|
||||
return
|
||||
}
|
||||
|
||||
if (isNaN(code.offset) || code.offset === null || code.offset === undefined) {
|
||||
saveObjectState()
|
||||
return
|
||||
}
|
||||
|
||||
if (code.offset < MIN_OFFSET) { code.offset = MIN_OFFSET }
|
||||
if (code.offset > MAX_OFFSET) { code.offset = MAX_OFFSET }
|
||||
|
||||
@@ -277,6 +281,18 @@ function newRateScale () {
|
||||
saveObjectState()
|
||||
return
|
||||
}
|
||||
|
||||
if (isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) {
|
||||
saveObjectState()
|
||||
return
|
||||
}
|
||||
if (isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined) {
|
||||
saveObjectState()
|
||||
return
|
||||
}
|
||||
|
||||
coordinateSystem.min.y = code.minValue
|
||||
coordinateSystem.max.y = code.maxValue
|
||||
} catch (err) {
|
||||
// we ignore errors here since most likely they will be parsing errors.
|
||||
}
|
||||
@@ -286,10 +302,10 @@ function newRateScale () {
|
||||
offsetTimer--
|
||||
scaleTimer--
|
||||
readObjectState()
|
||||
positioningphysics()
|
||||
positioningPhysics()
|
||||
}
|
||||
|
||||
function positioningphysics () {
|
||||
function positioningPhysics () {
|
||||
/* Container Limits */
|
||||
|
||||
let upCorner = {
|
||||
@@ -336,7 +352,7 @@ function newRateScale () {
|
||||
y: mouse.position.y + thisObject.offset
|
||||
}
|
||||
|
||||
thisObject.rate = getRateFromPoint(ratePoint, rateCalculationsContainer, timeLineCoordinateSystem)
|
||||
thisObject.rate = getRateFromPoint(ratePoint, rateCalculationsContainer, coordinateSystem)
|
||||
|
||||
/* rateScale Positioning */
|
||||
ratePoint = {
|
||||
@@ -376,8 +392,8 @@ function newRateScale () {
|
||||
|
||||
let rate = thisObject.rate
|
||||
|
||||
if (rate < timeLineCoordinateSystem.min.y) { rate = timeLineCoordinateSystem.min.y }
|
||||
if (rate > timeLineCoordinateSystem.max.y) { rate = timeLineCoordinateSystem.max.y }
|
||||
if (rate < coordinateSystem.min.y) { rate = coordinateSystem.min.y }
|
||||
if (rate > coordinateSystem.max.y) { rate = coordinateSystem.max.y }
|
||||
|
||||
let label = (rate - Math.trunc(rate)).toFixed(2)
|
||||
let labelArray = label.split('.')
|
||||
|
||||
@@ -32,7 +32,7 @@ function newTimeFrameScale () {
|
||||
let onMouseOverEventSubscriptionId
|
||||
let onMouseNotOverEventSubscriptionId
|
||||
|
||||
let timeLineCoordinateSystem
|
||||
let coordinateSystem
|
||||
let limitingContainer
|
||||
|
||||
let mouse = {
|
||||
@@ -69,8 +69,8 @@ function newTimeFrameScale () {
|
||||
thisObject.payload = undefined
|
||||
}
|
||||
|
||||
function initialize (pTimeLineCoordinateSystem, pLimitingContainer) {
|
||||
timeLineCoordinateSystem = pTimeLineCoordinateSystem
|
||||
function initialize (pCoordinateSystem, pLimitingContainer) {
|
||||
coordinateSystem = pCoordinateSystem
|
||||
limitingContainer = pLimitingContainer
|
||||
|
||||
readObjectState()
|
||||
@@ -114,10 +114,10 @@ function newTimeFrameScale () {
|
||||
|
||||
function physics () {
|
||||
readObjectState()
|
||||
positioningphysics()
|
||||
positioningPhysics()
|
||||
}
|
||||
|
||||
function positioningphysics () {
|
||||
function positioningPhysics () {
|
||||
/* Container Limits */
|
||||
|
||||
let upCorner = {
|
||||
|
||||
+7
-7
@@ -40,7 +40,7 @@ function newTimeScale () {
|
||||
let onMouseOverEventSubscriptionId
|
||||
let onMouseNotOverEventSubscriptionId
|
||||
|
||||
let timeLineCoordinateSystem
|
||||
let coordinateSystem
|
||||
let limitingContainer
|
||||
|
||||
let mouse = {
|
||||
@@ -62,13 +62,13 @@ function newTimeScale () {
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.payload = undefined
|
||||
|
||||
timeLineCoordinateSystem = undefined
|
||||
coordinateSystem = undefined
|
||||
limitingContainer = undefined
|
||||
mouse = undefined
|
||||
}
|
||||
|
||||
function initialize (pTimeLineCoordinateSystem, pLimitingContainer) {
|
||||
timeLineCoordinateSystem = pTimeLineCoordinateSystem
|
||||
function initialize (pCoordinateSystem, pLimitingContainer) {
|
||||
coordinateSystem = pCoordinateSystem
|
||||
limitingContainer = pLimitingContainer
|
||||
|
||||
onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
|
||||
@@ -195,10 +195,10 @@ function newTimeScale () {
|
||||
function physics () {
|
||||
scaleTimer--
|
||||
readObjectState()
|
||||
positioningphysics()
|
||||
positioningPhysics()
|
||||
}
|
||||
|
||||
function positioningphysics () {
|
||||
function positioningPhysics () {
|
||||
/* Container Limits */
|
||||
|
||||
let upCorner = {
|
||||
@@ -223,7 +223,7 @@ function newTimeScale () {
|
||||
y: 0
|
||||
}
|
||||
|
||||
let mouseDate = getDateFromPoint(timePoint, limitingContainer, timeLineCoordinateSystem)
|
||||
let mouseDate = getDateFromPoint(timePoint, limitingContainer, coordinateSystem)
|
||||
|
||||
thisObject.date = new Date(mouseDate)
|
||||
|
||||
|
||||
+14
-14
@@ -82,30 +82,30 @@ function pad (str, max) {
|
||||
return str.length < max ? pad('0' + str, max) : str
|
||||
}
|
||||
|
||||
function getDateFromPoint (point, container, timeLineCoordinateSystem) {
|
||||
function getDateFromPoint (point, container, coordinateSystem) {
|
||||
point = unTransformThisPoint(point, container)
|
||||
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height)
|
||||
point = coordinateSystem.unInverseTransform(point, container.frame.height)
|
||||
|
||||
let date = new Date(point.x)
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
function getRateFromPoint (point, container, timeLineCoordinateSystem) {
|
||||
function getRateFromPoint (point, container, coordinateSystem) {
|
||||
point = unTransformThisPoint(point, container)
|
||||
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height)
|
||||
point = coordinateSystem.unInverseTransform(point, container.frame.height)
|
||||
|
||||
return point.y
|
||||
}
|
||||
|
||||
function getMilisecondsFromPoint (point, container, timeLineCoordinateSystem) {
|
||||
function getMilisecondsFromPoint (point, container, coordinateSystem) {
|
||||
point = unTransformThisPoint(point, container)
|
||||
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height)
|
||||
point = coordinateSystem.unInverseTransform(point, container.frame.height)
|
||||
|
||||
return point.x
|
||||
}
|
||||
|
||||
function saveUserPosition (container, timeLineCoordinateSystem, position) {
|
||||
function saveUserPosition (container, coordinateSystem, position) {
|
||||
if (position === undefined) {
|
||||
position = {
|
||||
x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2,
|
||||
@@ -114,8 +114,8 @@ function saveUserPosition (container, timeLineCoordinateSystem, position) {
|
||||
}
|
||||
|
||||
let userPosition = {
|
||||
date: getDateFromPoint(position, container, timeLineCoordinateSystem),
|
||||
rate: getRateFromPoint(position, container, timeLineCoordinateSystem),
|
||||
date: getDateFromPoint(position, container, coordinateSystem),
|
||||
rate: getRateFromPoint(position, container, coordinateSystem),
|
||||
market: DEFAULT_MARKET,
|
||||
zoom: canvas.chartSpace.viewport.zoomTargetLevel
|
||||
}
|
||||
@@ -123,14 +123,14 @@ function saveUserPosition (container, timeLineCoordinateSystem, position) {
|
||||
window.localStorage.setItem('userPosition', JSON.stringify(userPosition))
|
||||
}
|
||||
|
||||
function getUserPosition (timeLineCoordinateSystem) {
|
||||
function getUserPosition (coordinateSystem) {
|
||||
let savedPosition = window.localStorage.getItem('userPosition')
|
||||
let userPosition
|
||||
|
||||
if (savedPosition === null) {
|
||||
userPosition = {
|
||||
date: (new Date()).toString(),
|
||||
rate: timeLineCoordinateSystem.max.y / 2,
|
||||
rate: coordinateSystem.max.y / 2,
|
||||
market: DEFAULT_MARKET,
|
||||
zoom: INITIAL_ZOOM_LEVEL
|
||||
}
|
||||
@@ -146,8 +146,8 @@ function getUserPosition (timeLineCoordinateSystem) {
|
||||
return userPosition
|
||||
}
|
||||
|
||||
function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignoreY, center, moveContainer) {
|
||||
let userPosition = getUserPosition(timeLineCoordinateSystem)
|
||||
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)
|
||||
@@ -159,7 +159,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor
|
||||
|
||||
/* Put this po int in the coordinate system of the canvas.chartSpace.viewport */
|
||||
|
||||
targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint)
|
||||
targetPoint = coordinateSystem.transformThisPoint(targetPoint)
|
||||
targetPoint = transformThisPoint(targetPoint, container)
|
||||
|
||||
let centerPoint
|
||||
|
||||
Reference in new issue
Block a user