Improvements at the Charting System

This commit is contained in:
Luis Fernando Molina committed 2020-01-31 17:20:49 +01:00
1 parent b92d650936
commit 0606ec5e37
27 files changed
+1022 -642

No files matched your search

+37 -27
View File
@@ -11,61 +11,71 @@ function newCoordinateSystem () {
let thisObject = {
min: undefined,
max: undefined,
maxHeight: undefined,
maxWidth: undefined,
scale: undefined,
eventHandler: undefined,
recalculateScale: recalculateScale,
transformThisPoint: transformThisPoint,
transformThisPoint2: transformThisPoint2,
unInverseTransform: unInverseTransform,
inverseTransformUncappedY: inverseTransformUncappedY,
initializeX: initializeX,
initializeY: initializeY,
initialize: initialize
initialize: initialize,
finalize: finalize
}
var min = {
thisObject.min = {
x: 0,
y: 0
}
thisObject.max = {
x: 0,
y: 0
}
thisObject.scale = {
x: 0,
y: 0
}
var max = {
x: 0,
y: 0
}
var scale = {
x: 0,
y: 0
}
thisObject.min = min
thisObject.max = max
thisObject.scale = scale
let maxHeight
thisObject.eventHandler = newEventHandler()
thisObject.eventHandler.name = 'Coordinate System'
return thisObject
function initialize (minValue, maxValue, maxWidth, pMaxHeight) {
/* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */
function finalize () {
thisObject.eventHandler.finalize()
thisObject.eventHandler = undefined
}
function initialize (minValue, maxValue, pMaxWidth, pMaxHeight) {
/* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */
thisObject.min.x = minValue.x // * 0.999; // 0.1% less
thisObject.max.x = maxValue.x // * 1.001; // 0.1% more
thisObject.min.y = minValue.y // * 0.999; // 0.1% less
thisObject.max.y = maxValue.y // * 1.001; // 0.1% more
/* Defines the initial Zoom level at center position. */
thisObject.maxWidth = pMaxWidth
thisObject.maxHeight = pMaxHeight
thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x)
thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y)
recalculateScale()
}
maxHeight = pMaxHeight
function recalculateScale () {
/* Defines the initial Zoom level at center position. */
thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x)
thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y)
thisObject.eventHandler.raiseEvent('Scale Changed')
}
function initializeX (minValue, maxValue, maxWidth) {
thisObject.min.x = minValue.x // * 0.999; // 0.1% less
thisObject.max.x = maxValue.x // * 1.001; // 0.1% more
thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x)
thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x)
}
function initializeY (minValue, maxValue, pMaxHeight) {
@@ -74,7 +84,7 @@ function newCoordinateSystem () {
thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y)
maxHeight = pMaxHeight
thisObject.maxHeight = pMaxHeight
}
function transformThisPoint (point) {
@@ -93,7 +103,7 @@ function newCoordinateSystem () {
point = {
x: (point.x - thisObject.min.x) * thisObject.scale.x,
y: maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y
y: thisObject.maxHeight - (point.y - thisObject.min.y) * thisObject.scale.y
}
return point
@@ -102,7 +112,7 @@ function newCoordinateSystem () {
function transformThisPoint2 (point) {
point = {
x: (point.x - thisObject.min.x) * thisObject.scale.x,
y: (maxHeight - point.y - thisObject.min.y) * thisObject.scale.y
y: (thisObject.maxHeight - point.y - thisObject.min.y) * thisObject.scale.y
}
return point
+17 -22
View File
@@ -15,6 +15,7 @@ function newPlottersManager () {
payload: undefined,
setDatetime: setDatetime,
setTimeFrame: setTimeFrame,
setCoordinateSystem: setCoordinateSystem,
draw: draw,
getContainer: getContainer,
initialize: initialize,
@@ -22,10 +23,9 @@ function newPlottersManager () {
}
let initializationReady = false
let layersPanel
let onLayerStatusChangedEventSuscriptionId
let coordinateSystem
setupContainer()
return thisObject
@@ -37,6 +37,7 @@ function newPlottersManager () {
function finalize () {
layersPanel.container.eventHandler.stopListening(onLayerStatusChangedEventSuscriptionId)
layersPanel = undefined
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
@@ -61,12 +62,10 @@ function newPlottersManager () {
connector = undefined
}
connectors = []
layersPanel = undefined
coordinateSystem = undefined
thisObject.container.finalize()
thisObject.container = undefined
thisObject.payload = undefined
}
@@ -80,23 +79,11 @@ function newPlottersManager () {
}
function initialize (pLayersPanel) {
try {
/* Remember the Layers Panel */
layersPanel = pLayersPanel
/* Remember the Layers Panel */
layersPanel = pLayersPanel
/* Listen to the event of change of status */
onLayerStatusChangedEventSuscriptionId = layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged)
/* Lets get all the cards that needs to be loaded. */
let loadingLayers = layersPanel.getLoadingLayers()
for (let i = 0; i < loadingLayers.length; i++) {
/* For each one, we will initialize the associated plotter. */
initializePlotter(loadingLayers[i])
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
}
/* Listen to the event of change of status */
onLayerStatusChangedEventSuscriptionId = layersPanel.container.eventHandler.listenToEvent('Layer Status Changed', onLayerStatusChanged)
}
function initializePlotter (layer) {
@@ -186,7 +173,7 @@ function newPlottersManager () {
plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2
plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2
plotter.fitFunction = thisObject.fitFunction
plotter.initialize(storage, datetime, timeFrame, onPlotterInizialized, product)
plotter.initialize(storage, datetime, timeFrame, coordinateSystem, onPlotterInizialized, product)
function onPlotterInizialized () {
try {
@@ -299,6 +286,14 @@ function newPlottersManager () {
}
}
function setCoordinateSystem (pCoordinateSystem) {
coordinateSystem = pCoordinateSystem
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
connector.plotter.setCoordinateSystem(coordinateSystem)
}
}
function getContainer (point) {
}
+122 -53
View File
@@ -45,6 +45,8 @@ function newTimeMachine () {
let syncWithDesignerLoop = 0
let timelineChartsMap = new Map()
let onViewportPositionChangedEventSuscriptionId
let onViewportZoomChangedEventSuscriptionId
let onMouseOverEventSuscriptionId
let onMouseNotOverEventSuscriptionId
let timeScaleValueEventSuscriptionId
@@ -70,6 +72,9 @@ function newTimeMachine () {
}
function finalize () {
canvas.chartSpace.viewport.eventHandler.stopListening(onViewportPositionChangedEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId)
if (thisObject.timeScale !== undefined) {
finalizeTimeScale()
}
@@ -92,15 +97,16 @@ function newTimeMachine () {
}
thisObject.timelineCharts = undefined
timelineChartsMap = undefined
thisObject.fitFunction = undefined
thisObject.container.finalize()
thisObject.container = undefined
thisObject.payload = undefined
mouse = undefined
timelineChartsMap = undefined
timeMachineCoordinateSystem.finalize()
timeMachineCoordinateSystem = undefined
}
function finalizeTimeScale () {
@@ -135,45 +141,48 @@ function newTimeMachine () {
loadFrame(thisObject.payload, thisObject.container.frame)
recalculateCoordinateSystem()
recalculateCurrentDatetime()
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
function onMouseOver (event) {
drawScales = true
mouse.position.x = event.x
mouse.position.y = event.y
if (thisObject.timeScale !== undefined) {
thisObject.timeScale.onMouseOverSomeTimeMachineContainer(event)
}
if (thisObject.rateScale !== undefined) {
thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event)
}
if (thisObject.timeFrameScale !== undefined) {
thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event)
}
}
onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
function onMouseNotOver (event) {
drawScales = false
if (thisObject.timeScale !== undefined) {
thisObject.timeScale.visible = false
}
if (thisObject.rateScale !== undefined) {
thisObject.rateScale.visible = false
}
if (thisObject.timeFrameScale !== undefined) {
thisObject.timeFrameScale.visible = false
}
}
onViewportPositionChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged)
onViewportZoomChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged)
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
}
function onMouseOver (event) {
drawScales = true
mouse.position.x = event.x
mouse.position.y = event.y
if (thisObject.timeScale !== undefined) {
thisObject.timeScale.onMouseOverSomeTimeMachineContainer(event)
}
if (thisObject.rateScale !== undefined) {
thisObject.rateScale.onMouseOverSomeTimeMachineContainer(event)
}
if (thisObject.timeFrameScale !== undefined) {
thisObject.timeFrameScale.onMouseOverSomeTimeMachineContainer(event)
}
}
function onMouseNotOver (event) {
drawScales = false
if (thisObject.timeScale !== undefined) {
thisObject.timeScale.visible = false
}
if (thisObject.rateScale !== undefined) {
thisObject.rateScale.visible = false
}
if (thisObject.timeFrameScale !== undefined) {
thisObject.timeFrameScale.visible = false
}
}
function initializeTimeScale () {
thisObject.timeScale = newTimeScale()
thisObject.timeScale.fitFunction = thisObject.fitFunction
@@ -184,10 +193,15 @@ function newTimeMachine () {
thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container)
function timeScaleValueChanged (event) {
thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale
recalculateCoordinateSystem()
if (event.isUserAction === true) {
moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, false, true, event.mousePosition, true)
let currentDate = getDateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem)
let currentRate = getRateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem)
thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale
recalculateCoordinateSystem()
moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, false, true, event.mousePosition)
} else {
thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale
recalculateCoordinateSystem()
}
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
}
@@ -206,10 +220,16 @@ function newTimeMachine () {
thisObject.rateScale.initialize(timeMachineCoordinateSystem, thisObject.container, thisObject.container)
function rateScaleValueChanged (event) {
thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale
recalculateCoordinateSystem()
if (event.isUserAction === true) {
moveToUserPosition(thisObject.container, timeMachineCoordinateSystem, true, false, event.mousePosition, true)
let currentDate = getDateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem)
let currentRate = getRateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem)
thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale
recalculateCoordinateSystem()
moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, true, false, event.mousePosition)
} else {
thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale
recalculateCoordinateSystem()
}
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
thisObject.container.eventHandler.raiseEvent('Upstream Rate Scale Value Changed', event)
@@ -226,7 +246,7 @@ function newTimeMachine () {
timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Value Changed', timeFrameScaleValueChanged)
timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver)
thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container)
thisObject.timeFrameScale.initialize(thisObject.container)
function timeFrameScaleValueChanged (event) {
let currentTimeFrame = timeFrame
@@ -249,7 +269,7 @@ function newTimeMachine () {
function getContainer (point, purpose) {
let container
if (thisObject.rateScale !== undefined) {
if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) {
container = thisObject.rateScale.getContainer(point)
if (container !== undefined) {
if (container.isForThisPurpose(purpose)) {
@@ -258,7 +278,7 @@ function newTimeMachine () {
}
}
if (thisObject.timeScale !== undefined) {
if (thisObject.timeScale !== undefined && thisObject.timeScale.isVisible === true) {
container = thisObject.timeScale.getContainer(point)
if (container !== undefined) {
if (container.isForThisPurpose(purpose)) {
@@ -267,7 +287,7 @@ function newTimeMachine () {
}
}
if (thisObject.timeFrameScale !== undefined) {
if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) {
container = thisObject.timeFrameScale.getContainer(point)
if (container !== undefined) {
if (container.isForThisPurpose(purpose)) {
@@ -292,6 +312,39 @@ function newTimeMachine () {
}
}
function onViewportZoomChanged (event) {
if (thisObject.container.frame.isInViewPort()) {
recalculateCurrentDatetime()
}
}
function onViewportPositionChanged () {
if (thisObject.container.frame.isInViewPort()) {
recalculateCurrentDatetime()
}
}
function recalculateCurrentDatetime () {
/*
The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that we
must calculate.
*/
let center = {
x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.bottomLeft.x) / 2,
y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) / 2
}
center = unTransformThisPoint(center, thisObject.container)
center = timeMachineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height)
datetime = new Date(center.x)
for (let i = 0; i < thisObject.timelineCharts.length; i++) {
let timelineChart = thisObject.timelineCharts[i]
timelineChart.setDatetime(datetime)
}
}
function fitFunction (point, fullVisible, margin, topMargin, bottomMargin) {
/* We prevent a point to be out of the container AND out of the Chart Space in general */
@@ -489,12 +542,10 @@ function newTimeMachine () {
}
if (drawScales === true) {
if (thisObject.timeScale !== undefined) { thisObject.timeScale.draw() }
if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() }
if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() }
if (thisObject.timeScale !== undefined && thisObject.timeScale.isVisible === true) { thisObject.timeScale.draw() }
if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.draw() }
if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.draw() }
}
thisObject.container.frame.draw(false, true, false, thisObject.fitFunction)
} else {
let icon = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type)
if (icon !== undefined) {
@@ -527,10 +578,18 @@ function newTimeMachine () {
}
if (drawScales === true) {
if (thisObject.timeScale !== undefined) { thisObject.timeScale.drawForeground() }
if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() }
if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() }
if (thisObject.timeScale !== undefined && thisObject.timeScale.isVisible === true) { thisObject.timeScale.drawForeground() }
if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.drawForeground() }
if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.drawForeground() }
}
let style = {
color: UI_COLOR.BLACK,
opacity: 1,
lineWidth: 1,
lineDash: [1, 3]
}
thisObject.container.frame.draw(false, true, false, thisObject.fitFunction, style)
}
}
@@ -545,6 +604,16 @@ function newTimeMachine () {
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4
}
if (thisObject.timeScale !== undefined) {
minValue.x = thisObject.timeScale.fromDate
maxValue.x = thisObject.timeScale.toDate
}
if (thisObject.rateScale !== undefined) {
minValue.y = thisObject.rateScale.minValue
maxValue.y = thisObject.rateScale.maxValue
}
timeMachineCoordinateSystem.initialize(
minValue,
maxValue,
+48 -67
View File
@@ -18,6 +18,7 @@ function newTimelineChart () {
layersManager: undefined,
plotterManager: undefined,
upstreamTimeFrame: undefined,
setDatetime: setDatetime,
setTimeFrame: setTimeFrame,
physics: physics,
draw: draw,
@@ -30,13 +31,11 @@ function newTimelineChart () {
let timeMachineCoordinateSystem
let timelineChartCoordinateSystem = newCoordinateSystem()
let coordinateSystem
let layersPanel
let layersPanelHandle
let onViewportPositionChangedEventSuscriptionId
let onViewportZoomChangedEventSuscriptionId
let onMouseOverEventSuscriptionId
let onMouseNotOverEventSuscriptionId
let rateScaleValueEventSuscriptionId
@@ -46,6 +45,7 @@ function newTimelineChart () {
let rateScaleUpstreamDimensionsEventSuscriptionId
let timeFrameScaleEventSuscriptionId
let timeFrameScaleMouseOverEventSuscriptionId
let scaleChangedEventSubscriptionId
let drawScales = false
let mouse = {
@@ -65,6 +65,8 @@ function newTimelineChart () {
}
function finalize () {
coordinateSystem.eventHandler.stopListening(timelineChartCoordinateSystem)
if (thisObject.layersManager !== undefined) {
finalizeLayersManager()
}
@@ -77,17 +79,21 @@ function newTimelineChart () {
finalizeTimeFrameScale()
}
canvas.chartSpace.viewport.eventHandler.stopListening(onViewportPositionChangedEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(onViewportZoomChangedEventSuscriptionId)
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId)
thisObject.container.finalize()
thisObject.container = undefined
thisObject.payload = undefined
mouse = undefined
logger = undefined
timeMachineCoordinateSystem = undefined
timelineChartCoordinateSystem.finalize()
timelineChartCoordinateSystem = undefined
coordinateSystem = undefined
layersPanel = undefined
layersPanelHandle = undefined
}
function finalizeLayersManager () {
@@ -137,16 +143,14 @@ function newTimelineChart () {
/* We load the logow we will need for the background. */
timeMachineCoordinateSystem = pTimeMachineCoordinateSystem
coordinateSystem = timeMachineCoordinateSystem
onScaleChanged()
timeFrame = INITIAL_TIME_PERIOD
recalculateCurrentDatetime()
/* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */
onViewportPositionChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Position Changed', onViewportPositionChanged)
onViewportZoomChangedEventSuscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent('Zoom Changed', onViewportZoomChanged)
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
scaleChangedEventSubscriptionId = timeMachineCoordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function initializeLayersManager () {
@@ -166,9 +170,10 @@ function newTimelineChart () {
thisObject.plotterManager.fitFunction = thisObject.fitFunction
thisObject.plotterManager.payload = thisObject.payload
thisObject.plotterManager.initialize(thisObject.layersManager, DEFAULT_EXCHANGE, DEFAULT_MARKET)
thisObject.plotterManager.initialize(thisObject.layersManager)
thisObject.plotterManager.setTimeFrame(timeFrame)
thisObject.plotterManager.setDatetime(datetime)
thisObject.plotterManager.setCoordinateSystem(coordinateSystem)
}
function initializeRateScale () {
@@ -190,7 +195,7 @@ function newTimelineChart () {
}
function rateScaleUpstreamChanged (event) {
thisObject.rateScale.setScale(event.scale)
// thisObject.rateScale.setScale(event.scale)
}
function rateScaleOffsetChanged (event) {
@@ -215,7 +220,7 @@ function newTimelineChart () {
timeFrameScaleEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('Time Frame Value Changed', timeFrameScaleValueChanged)
timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOverScale', timeFrameScaleMouseOver)
thisObject.timeFrameScale.initialize(timeMachineCoordinateSystem, thisObject.container.parentContainer)
thisObject.timeFrameScale.initialize(thisObject.container.parentContainer)
function timeFrameScaleValueChanged (event) {
let currentTimeFrame = timeFrame
@@ -229,10 +234,15 @@ function newTimelineChart () {
function timeFrameScaleMouseOver (event) {
thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event)
saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event)
}
}
function onScaleChanged () {
timelineChartCoordinateSystem.min.x = timeMachineCoordinateSystem.min.x
timelineChartCoordinateSystem.max.x = timeMachineCoordinateSystem.max.x
timelineChartCoordinateSystem.recalculateScale()
}
function setTimeFrame (pTimeFrame) {
timeFrame = pTimeFrame
if (thisObject.plotterManager !== undefined) {
@@ -240,6 +250,13 @@ function newTimelineChart () {
}
}
function setDatetime (pDatetime) {
datetime = pDatetime
if (thisObject.plotterManager !== undefined) {
thisObject.plotterManager.setDatetime(datetime)
}
}
function onMouseOver (event) {
/* This event gets to the timelinechart container because it inherits it from the time machine container, which is the one raising Mouse Over and Mouse not Over Events to its children. */
drawScales = true
@@ -254,8 +271,6 @@ function newTimelineChart () {
mouse.position.x = event.x
mouse.position.y = event.y
saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event)
}
function onMouseNotOver (event) {
@@ -270,51 +285,10 @@ function newTimelineChart () {
}
}
function onViewportZoomChanged (event) {
if (thisObject.container.frame.isInViewPort()) {
recalculateCurrentDatetime()
}
}
function onViewportPositionChanged () {
if (thisObject.container.frame.isInViewPort()) {
recalculateCurrentDatetime()
}
}
function recalculateCurrentDatetime () {
/*
The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that we
must calculate.
*/
let center = {
x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.bottomLeft.x) / 2,
y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) / 2
}
center = unTransformThisPoint(center, thisObject.container)
if (thisObject.rateScale === undefined) {
center = timeMachineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height)
} else {
center = timelineChartCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height)
}
let newDate = new Date(center.x)
datetime = newDate
if (thisObject.plotterManager !== undefined) {
thisObject.plotterManager.setDatetime(datetime)
}
}
function getContainer (point, purpose) {
let container
if (thisObject.rateScale !== undefined) {
if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) {
container = thisObject.rateScale.getContainer(point)
if (container !== undefined) {
if (container.isForThisPurpose(purpose)) {
@@ -323,7 +297,7 @@ function newTimelineChart () {
}
}
if (thisObject.timeFrameScale !== undefined) {
if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) {
container = thisObject.timeFrameScale.getContainer(point)
if (container !== undefined) {
if (container.isForThisPurpose(purpose)) {
@@ -368,9 +342,11 @@ function newTimelineChart () {
}
if (thisObject.payload.node.rateScale === undefined && thisObject.rateScale !== undefined) {
finalizeRateScale()
coordinateSystem = timeMachineCoordinateSystem
}
if (thisObject.payload.node.rateScale !== undefined && thisObject.rateScale === undefined) {
initializeRateScale()
coordinateSystem = timelineChartCoordinateSystem
}
if (thisObject.payload.node.timeFrameScale === undefined && thisObject.timeFrameScale !== undefined) {
finalizeTimeFrameScale()
@@ -401,8 +377,8 @@ function newTimelineChart () {
function draw () {
if (thisObject.container.frame.isInViewPort()) {
if (drawScales === true) {
if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.draw() }
if (thisObject.rateScale !== undefined) { thisObject.rateScale.draw() }
if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.draw() }
if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.draw() }
}
}
}
@@ -410,8 +386,8 @@ function newTimelineChart () {
function drawForeground () {
if (thisObject.container.frame.isInViewPort()) {
if (drawScales === true) {
if (thisObject.timeFrameScale !== undefined) { thisObject.timeFrameScale.drawForeground() }
if (thisObject.rateScale !== undefined) { thisObject.rateScale.drawForeground() }
if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { thisObject.timeFrameScale.drawForeground() }
if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { thisObject.rateScale.drawForeground() }
}
}
}
@@ -422,15 +398,20 @@ function newTimelineChart () {
function recalculateCoordinateSystem () {
let minValue = {
x: MIN_PLOTABLE_DATE.valueOf(),
x: timelineChartCoordinateSystem.min.x,
y: 0
}
let maxValue = {
x: MAX_PLOTABLE_DATE.valueOf(),
x: timelineChartCoordinateSystem.max.x,
y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4
}
if (thisObject.rateScale !== undefined) {
minValue.y = thisObject.rateScale.minValue
maxValue.y = thisObject.rateScale.maxValue
}
timelineChartCoordinateSystem.initialize(
minValue,
maxValue,
+8 -10
View File
@@ -237,9 +237,9 @@ function newFrame () {
}
}
function draw (drawGrid, drawBorders, drawBackground, fitFunction) {
function draw (drawGrid, drawBorders, drawBackground, fitFunction, style) {
if (drawBorders === true) {
borders(fitFunction)
borders(fitFunction, style)
}
if (drawGrid === true) {
@@ -331,7 +331,7 @@ function newFrame () {
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
}
function borders (fitFunction) {
function borders (fitFunction, style) {
/* Lest get the important points of the drawing so as to apply the needed transformations. */
let point1
@@ -359,8 +359,7 @@ function newFrame () {
y: thisObject.height
}
/* Now the transformations. */
/* Now the transformations. */
point1 = transformThisPoint(point1, thisObject.container)
point2 = transformThisPoint(point2, thisObject.container)
point3 = transformThisPoint(point3, thisObject.container)
@@ -373,8 +372,7 @@ function newFrame () {
point4 = fitFunction(point4)
}
/* Lets start the drawing. */
/* Lets start the drawing. */
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x, point1.y)
browserCanvasContext.lineTo(point2.x, point2.y)
@@ -383,9 +381,9 @@ function newFrame () {
browserCanvasContext.lineTo(point1.x, point1.y)
browserCanvasContext.closePath()
browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)'
browserCanvasContext.lineWidth = 1
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.strokeStyle = 'rgba(' + style.color + ', ' + style.opacity + ')'
browserCanvasContext.lineWidth = style.lineWidth
browserCanvasContext.setLineDash(style.lineDash)
browserCanvasContext.stroke()
browserCanvasContext.closePath()
+1 -1
View File
@@ -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 MAX_DEFAULT_RATE_SCALE_VALUE = 19900; // This is needed to know the scale of the market time line.
const MAX_DEFAULT_RATE_SCALE_VALUE = 35000; // 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;
+81 -44
View File
@@ -6,7 +6,7 @@ function newLayersPanel () {
layers: [],
payload: undefined,
isVisible: true,
getLoadingLayers: getLoadingLayers,
panelTabButton: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
@@ -26,16 +26,15 @@ function newLayersPanel () {
let firstVisibleLayer = 1
const LAYER_SEPARATION = 0
let panelTabButton
let visible = true
let heatherHeight = 40
let headerHeight = 40
let footerHeight = 10
let layerHeight = 70
let desiredVisibleLayers = 5
let posibleVisibleLayers = 5
let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight
let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight
let desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight
let onMouseWheelEventSuscriptionId
return thisObject
@@ -43,8 +42,8 @@ function newLayersPanel () {
function finalize () {
thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId)
panelTabButton.finalize()
panelTabButton = undefined
thisObject.panelTabButton.finalize()
thisObject.panelTabButton = undefined
layersMap = undefined
visibleLayers = undefined
@@ -59,31 +58,75 @@ function newLayersPanel () {
thisObject.container.name = thisObject.payload.node.name
thisObject.container.frame.containerName = thisObject.container.name
thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL
thisObject.container.frame.height = heatherHeight
thisObject.container.frame.height = headerHeight
let position = {
let position = { // Default position
x: canvas.chartSpace.viewport.visibleArea.topLeft.x,
y: canvas.chartSpace.viewport.visibleArea.topLeft.y// canvas.chartSpace.viewport.visibleArea.bottomLeft.y - thisObject.container.frame.height
y: canvas.chartSpace.viewport.visibleArea.topLeft.y
}
thisObject.container.frame.position = position
loadFrame(thisObject.payload, thisObject.container.frame)
panelTabButton = newPanelTabButton()
panelTabButton.parentContainer = thisObject.container
panelTabButton.container.frame.parentFrame = thisObject.container.frame
panelTabButton.fitFunction = thisObject.fitFunction
panelTabButton.initialize()
thisObject.panelTabButton = newPanelTabButton()
thisObject.panelTabButton.parentContainer = thisObject.container
thisObject.panelTabButton.container.frame.parentFrame = thisObject.container.frame
thisObject.panelTabButton.fitFunction = thisObject.fitFunction
thisObject.panelTabButton.initialize()
onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers')
if (storedValue >= 0 && storedValue <= 20) {
desiredVisibleLayers = storedValue
}
readObjectState()
isInitialized = true
}
function saveObjectStateVisibleLayers () {
savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers)
}
function saveObjectStatePanelLocation () {
savePropertyAtNodeConfig(thisObject.payload, 'panelLocation', thisObject.panelTabButton.status)
}
function readObjectState () {
let storedValue
storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'visibleLayers')
if (isNaN(storedValue) || storedValue === null || storedValue === undefined) {
// not using this value
saveObjectStateVisibleLayers() // this overrides any invalid value at the config.
return
} else {
if (storedValue < 0) { storedValue = 0 }
if (storedValue > thisObject.layers.length) {
storedValue = thisObject.layers.length
}
if (storedValue !== desiredVisibleLayers) {
desiredVisibleLayers = storedValue
desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
calculateVisbleLayers()
}
}
storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'panelLocation')
if (storedValue === null || storedValue === undefined) {
// not using this value
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
return
} else {
if (storedValue !== 'up' && storedValue !== 'down') {
saveObjectStatePanelLocation() // this overrides any invalid value at the config.
return
}
thisObject.panelTabButton.setStatus(storedValue)
saveObjectStatePanelLocation()
}
}
function removeLayer (id) {
let layer = layersMap.get(id)
layersMap.delete(id)
@@ -132,38 +175,38 @@ function newLayersPanel () {
delta = 1
}
if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < heatherHeight) {
if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < headerHeight) { // Mouse wheel over the header, not a layer
desiredVisibleLayers = desiredVisibleLayers + delta
if (desiredVisibleLayers < 0) { desiredVisibleLayers = 0 }
if (desiredVisibleLayers > thisObject.layers.length) { desiredVisibleLayers = thisObject.layers.length }
} else {
firstVisibleLayer = firstVisibleLayer + delta
}
desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + heatherHeight + footerHeight
desiredPanelHeight = (layerHeight + LAYER_SEPARATION) * desiredVisibleLayers + headerHeight + footerHeight
calculateVisbleLayers()
savePropertyAtNodeConfig(thisObject.payload, 'visibleLayers', desiredVisibleLayers)
saveObjectStateVisibleLayers()
}
function panelSizePhysics () {
let viewPortHeight = canvas.chartSpace.viewport.visibleArea.bottomLeft.y - canvas.chartSpace.viewport.visibleArea.topLeft.y
if (viewPortHeight < heatherHeight) {
if (viewPortHeight < headerHeight) {
visible = false
} else {
visible = true
}
if (desiredPanelHeight > viewPortHeight) {
posibleVisibleLayers = Math.trunc((viewPortHeight - heatherHeight - footerHeight) / (layerHeight + LAYER_SEPARATION))
posibleVisibleLayers = Math.trunc((viewPortHeight - headerHeight - footerHeight) / (layerHeight + LAYER_SEPARATION))
} else {
posibleVisibleLayers = desiredVisibleLayers
}
if (thisObject.layers.length < posibleVisibleLayers) { posibleVisibleLayers = thisObject.layers.length }
if (posibleVisibleLayers === 0) {
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight
} else {
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + heatherHeight + footerHeight
posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight
}
thisObject.container.frame.height = posiblePanelHeight
@@ -183,7 +226,7 @@ function newLayersPanel () {
let layer = thisObject.layers[i]
layer.container.frame.position.x = 0
layer.container.frame.position.y = (layerHeight + LAYER_SEPARATION) * visibleLayers.length + heatherHeight
layer.container.frame.position.y = (layerHeight + LAYER_SEPARATION) * visibleLayers.length + headerHeight
/* Add to Visible Product Array */
visibleLayers.push(layer)
@@ -195,23 +238,10 @@ function newLayersPanel () {
thisObject.container.eventHandler.raiseEvent('Layer Status Changed', layer)
}
function getLoadingLayers () {
/* Returns all thisObject.layers which status is LOADING */
let onProducts = []
for (let i = 0; i < thisObject.layers.length; i++) {
if (thisObject.layers[i].status === LAYER_STATUS.LOADING) {
onProducts.push(thisObject.layers[i])
}
}
return onProducts
}
function getContainer (point) {
let container
container = panelTabButton.getContainer(point)
container = thisObject.panelTabButton.getContainer(point)
if (container !== undefined) { return container }
/* First we check if thisObject point is inside thisObject space. */
@@ -255,8 +285,15 @@ function newLayersPanel () {
}
}
function syncWithConfigPhysics () {
readObjectState()
}
function physics () {
if (isInitialized === false) { return }
thisObject.panelTabButton.physics()
saveFrame(thisObject.payload, thisObject.container.frame)
syncWithConfigPhysics()
/*
The overall idea here is that we need to keep syncronized the panel with the layers that are
@@ -339,7 +376,7 @@ function newLayersPanel () {
visibleLayers[i].draw()
}
drawScrollBar()
panelTabButton.draw()
thisObject.panelTabButton.draw()
}
function drawHeader () {
@@ -376,7 +413,7 @@ function newLayersPanel () {
let xOffset = 4
let barTopPoint = {
x: thisObject.container.frame.width - xOffset,
y: heatherHeight
y: headerHeight
}
let barBottomPoint = {
x: thisObject.container.frame.width - xOffset,
@@ -386,7 +423,7 @@ function newLayersPanel () {
let handleHeight = (posibleVisibleLayers * (layerHeight + LAYER_SEPARATION)) * ratio
let handleTopPoint = {
x: thisObject.container.frame.width - xOffset,
y: heatherHeight + (layerHeight + LAYER_SEPARATION) * ratio * (firstVisibleLayer - 1)
y: headerHeight + (layerHeight + LAYER_SEPARATION) * ratio * (firstVisibleLayer - 1)
}
let handleBottomPoint = {
x: thisObject.container.frame.width - xOffset,
+66 -53
View File
@@ -3,6 +3,9 @@ function newPanelTabButton () {
container: undefined,
fitFunction: undefined,
parentContainer: undefined,
status: undefined,
setStatus: setStatus,
physics: physics,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize,
@@ -19,9 +22,9 @@ function newPanelTabButton () {
thisObject.container.frame.containerName = 'Panel Tab Button'
/* Animation to hide the pannel */
let tabStatus = 'visible'
let visiblePosition = {}
let hiddenPosition = {}
thisObject.status = 'up'
let upPosition = {}
let downPosition = {}
let transitionPosition = {}
let onMouseClickEventSuscriptionId
@@ -34,9 +37,9 @@ function newPanelTabButton () {
thisObject.fitFunction = undefined
thisObject.parentContainer = undefined
tabStatus = undefined
visiblePosition = undefined
hiddenPosition = undefined
thisObject.status = undefined
upPosition = undefined
downPosition = undefined
transitionPosition = undefined
}
@@ -45,20 +48,20 @@ function newPanelTabButton () {
thisObject.container.frame.height = 10
var position = {
x: thisObject.parentContainer.frame.width - 15,
y: 2
x: thisObject.parentContainer.frame.width - 14,
y: 1
}
thisObject.container.frame.position = position
visiblePosition.x = thisObject.parentContainer.frame.position.x
visiblePosition.y = thisObject.parentContainer.frame.position.y
upPosition.x = thisObject.parentContainer.frame.position.x
upPosition.y = thisObject.parentContainer.frame.position.y
hiddenPosition.x = thisObject.parentContainer.frame.position.x
hiddenPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y
downPosition.x = thisObject.parentContainer.frame.position.x
downPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y
transitionPosition.x = visiblePosition.x
transitionPosition.y = visiblePosition.y
transitionPosition.x = upPosition.x
transitionPosition.y = upPosition.y
/* Lets listen to our own events to react when we have a Mouse Click */
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
@@ -66,55 +69,65 @@ function newPanelTabButton () {
isInitialized = true
}
function setStatus (value) {
if (value === 'up' && thisObject.status === 'down') {
thisObject.status = 'going up'
}
if (value === 'down' && thisObject.status === 'up') {
thisObject.status = 'going down'
}
}
function onMouseClick (event) {
if (tabStatus === 'visible') {
visiblePosition.x = thisObject.parentContainer.frame.position.x
visiblePosition.y = thisObject.parentContainer.frame.position.y
if (thisObject.status === 'up') {
transitionPosition.x = upPosition.x
transitionPosition.y = upPosition.y
hiddenPosition.x = thisObject.parentContainer.frame.position.x
hiddenPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y
transitionPosition.x = visiblePosition.x
transitionPosition.y = visiblePosition.y
thisObject.parentContainer.isDraggeable = false
thisObject.parentContainer.isWheelable = false
tabStatus = 'going down'
thisObject.status = 'going down'
} else {
thisObject.parentContainer.isDraggeable = true
thisObject.parentContainer.isWheelable = true
tabStatus = 'going up'
transitionPosition.x = downPosition.x
transitionPosition.y = downPosition.y
thisObject.status = 'going up'
}
}
function physics () {
if (isInitialized === false) { return }
upPosition.x = thisObject.parentContainer.frame.position.x
upPosition.y = canvas.chartSpace.viewport.visibleArea.topRight.y
downPosition.x = thisObject.parentContainer.frame.position.x
downPosition.y = canvas.chartSpace.viewport.visibleArea.bottomRight.y
if (thisObject.status === 'going down') {
if (transitionPosition.y < downPosition.y) {
transitionPosition.y = transitionPosition.y + 50
thisObject.parentContainer.frame.position.y = transitionPosition.y
} else {
thisObject.parentContainer.frame.position.y = downPosition.y
thisObject.status = 'down'
}
}
if (thisObject.status === 'going up') {
if (transitionPosition.y > upPosition.y) {
transitionPosition.y = transitionPosition.y - 50
thisObject.parentContainer.frame.position.y = transitionPosition.y
} else {
thisObject.parentContainer.frame.position.y = upPosition.y
thisObject.status = 'up'
}
}
}
function draw () {
return
if (isInitialized === false) { return }
drawButton()
if (tabStatus === 'going down') {
if (transitionPosition.y < hiddenPosition.y) {
transitionPosition.y = transitionPosition.y + 50
thisObject.parentContainer.frame.position.y = transitionPosition.y
} else {
thisObject.parentContainer.frame.position.y = hiddenPosition.y
tabStatus = 'hidden'
}
}
if (tabStatus === 'going up') {
if (transitionPosition.y > visiblePosition.y) {
transitionPosition.y = transitionPosition.y - 50
thisObject.parentContainer.frame.position.y = transitionPosition.y
} else {
thisObject.parentContainer.frame.position.y = visiblePosition.y
tabStatus = 'visible'
}
}
}
function getContainer (point) {
return
let container
/* First we check if thisObject point is inside thisObject space. */
@@ -135,8 +148,8 @@ function newPanelTabButton () {
let point2
let point3
switch (tabStatus) {
case 'visible': {
switch (thisObject.status) {
case 'up': {
point1 = {
x: 3,
y: 3
@@ -190,7 +203,7 @@ function newPanelTabButton () {
break
}
case 'hidden': {
case 'down': {
point1 = {
x: 3,
y: thisObject.container.frame.height - 3
+50 -28
View File
@@ -6,32 +6,23 @@ function newPlotter () {
logger.fileName = MODULE_NAME
let thisObject = {
/* Events declared outside the plotter. */
currentRecord: undefined,
container: undefined,
onDailyFileLoaded: onDailyFileLoaded,
// Main functions and properties.
initialize: initialize,
finalize: finalize,
container: undefined,
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
recalculateScale: recalculateScale,
draw: draw,
// Secondary functions and properties.
currentRecord: undefined // ---> Check Here
setCoordinateSystem: setCoordinateSystem,
draw: draw
}
let container = newContainer()
container.initialize()
thisObject.container = container
let coordinateSystem = newCoordinateSystem() // Needed to be able to plot on the timeline.
let coordinateSystem
let slotCoordinateSystem // Needed to be able to plot on a slot over the timeline.
let plotterModuleConfig
let slotHeight = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 10 // This is the amount of slots available
@@ -51,7 +42,9 @@ function newPlotter () {
let productDefinition // Here we store a snapshot of the product definition which references this plotter.
let records = [] // We will have the information to be plotted here.
let userPositionDate
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
@@ -59,6 +52,7 @@ function newPlotter () {
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let onDisplaceEventSubscriptionId
let scaleChangedEventSubscriptionId
let logged = false
return thisObject
@@ -66,6 +60,7 @@ function newPlotter () {
function finalize () {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId)
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId)
@@ -84,6 +79,7 @@ function newPlotter () {
marketFile = undefined
fileCursor = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
slotCoordinateSystem = undefined
plotterModuleConfig = undefined
@@ -96,7 +92,7 @@ function newPlotter () {
}
}
function initialize (pStorage, pDatetime, pTimeFrame, callBackFunction, pProductDefinition) {
function initialize (pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction, pProductDefinition) {
try {
/* Store the information received. */
marketFiles = pStorage.marketFiles[0]
@@ -104,14 +100,14 @@ function newPlotter () {
datetime = pDatetime
timeFrame = pTimeFrame
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
productDefinition = pProductDefinition
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS) // This file is the one processed faster.
recalculateScale()
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame)
fileCursor = dailyFiles.getFileCursor(pTimeFrame)
@@ -123,11 +119,11 @@ function newPlotter () {
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent('Files Updated', onMarketFilesUpdated)
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent('Files Updated', onDailyFilesUpdated)
onDisplaceEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onDisplace', onDisplace)
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
recalculate()
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculateScale()
recalculate()
})
@@ -138,6 +134,24 @@ function newPlotter () {
}
}
function initializeCoordinateSystem () {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem () {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged () {
mustRecalculateDataPoints = true
recalculate()
}
function onMouseOver (event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function onMarketFilesUpdated () {
try {
let newMarketFile = marketFiles.getFile(timeFrame)
@@ -209,6 +223,12 @@ function newPlotter () {
datetime = pDatetime
}
function setCoordinateSystem (pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded (event) {
try {
if (event.currentValue === event.totalValue) {
@@ -260,7 +280,10 @@ function newPlotter () {
}
}
if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) {
if (
(record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) &&
(record.end >= coordinateSystem.min.x && record.begin <= coordinateSystem.max.x)
) {
record.previous = previous
jsonifiedArray.push(record)
previous = record
@@ -483,9 +506,6 @@ function newPlotter () {
function plotChart () {
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
/* Clean the pannel at places where there is no record. */
let currentRecord = {
data: undefined
@@ -517,6 +537,12 @@ function newPlotter () {
beginPoint = transformThisPoint(beginPoint, thisObject.container)
endPoint = transformThisPoint(endPoint, thisObject.container)
beginPoint = canvas.chartSpace.viewport.fitIntoVisibleArea(beginPoint)
endPoint = canvas.chartSpace.viewport.fitIntoVisibleArea(endPoint)
beginPoint = thisObject.fitFunction(beginPoint)
endPoint = thisObject.fitFunction(endPoint)
if (endPoint.x < canvas.chartSpace.viewport.visibleArea.bottomLeft.x || beginPoint.x > canvas.chartSpace.viewport.visibleArea.bottomRight.x) {
continue
}
@@ -566,13 +592,9 @@ function newPlotter () {
That means that the first thing we allways need to do is to trasform these points to the coordinate system of the timeline.
*/
dataPoint = coordinateSystem.transformThisPoint(dataPoint)
/*
The browser canvas object does not care about our timeline and its coordinate system. In order to draw on a html canvas we
need the points to be converted into the canvas coordinate system.
Next we transform again to the screen coordinate system.
*/
dataPoint = transformThisPoint(dataPoint, thisObject.container)
dataPoint = canvas.chartSpace.viewport.fitIntoVisibleArea(dataPoint)
dataPoint = thisObject.fitFunction(dataPoint)
/* Store the data point at the local map */
dataPoints.set(point.id, dataPoint)
+76 -71
View File
@@ -10,6 +10,7 @@ function newRateScale () {
offset: undefined,
minValue: undefined,
maxValue: undefined,
isVisible: true,
setScale: setScale,
onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer,
physics: physics,
@@ -88,6 +89,9 @@ function newRateScale () {
limitingContainer = pLimitingContainer
rateCalculationsContainer = pRateCalculationsContainer
thisObject.minValue = coordinateSystem.min.y
thisObject.maxValue = coordinateSystem.max.y
onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
@@ -173,26 +177,17 @@ function newRateScale () {
if (thisObject.scale > MAX_SCALE) { thisObject.scale = MAX_SCALE }
}
if (
thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE &&
thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE
) {
event.scale = DEFAULT_SCALE
} else {
event.scale = thisObject.scale
}
event.isUserAction = true
thisObject.container.eventHandler.raiseEvent('Rate Scale Value Changed', event)
saveObjectState()
offsetTimer = 0
scaleTimer = 100
finishScaleChange(event)
}
}
function setScale (scale) {
thisObject.scale = scale
let event = {}
finishScaleChange(event)
}
function finishScaleChange (event) {
if (
thisObject.scale <= DEFAULT_SCALE + SNAP_THRESHOLD_SCALE &&
thisObject.scale >= DEFAULT_SCALE - SNAP_THRESHOLD_SCALE
@@ -221,7 +216,9 @@ function newRateScale () {
code.scale = thisObject.scale / MAX_SCALE * 100
code.scale = code.scale.toFixed(0)
code.offset = thisObject.offset
thisObject.payload.node.code = JSON.stringify(code)
code.minValue = thisObject.minValue
code.maxValue = thisObject.maxValue
thisObject.payload.node.code = JSON.stringify(code, null, 4)
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
@@ -232,67 +229,63 @@ function newRateScale () {
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('Rate Scale Value Changed', event)
// not using this value
} else {
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('Rate Scale Value Changed', event)
}
}
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 }
if (code.offset !== thisObject.offset) {
thisObject.offset = code.offset
let event = {}
if (
thisObject.offset <= DEFAULT_OFFSET + SNAP_THRESHOLD_OFFSET &&
thisObject.offset >= DEFAULT_OFFSET - SNAP_THRESHOLD_OFFSET
) {
event.offset = 0
} else {
event.offset = -thisObject.offset
}
thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event)
// not using this value
} else {
saveObjectState()
return
if (code.offset < MIN_OFFSET) { code.offset = MIN_OFFSET }
if (code.offset > MAX_OFFSET) { code.offset = MAX_OFFSET }
if (code.offset !== thisObject.offset) {
thisObject.offset = code.offset
let event = {}
if (
thisObject.offset <= DEFAULT_OFFSET + SNAP_THRESHOLD_OFFSET &&
thisObject.offset >= DEFAULT_OFFSET - SNAP_THRESHOLD_OFFSET
) {
event.offset = 0
} else {
event.offset = -thisObject.offset
}
thisObject.container.eventHandler.raiseEvent('Rate Scale Offset Changed', event)
}
}
if (isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) {
saveObjectState()
return
if (
(isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) ||
(isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined)
) {
// not using this value
} else {
if (thisObject.minValue !== code.minValue || thisObject.maxValue !== code.maxValue) {
thisObject.minValue = code.minValue
thisObject.maxValue = code.maxValue
coordinateSystem.min.y = thisObject.minValue
coordinateSystem.max.y = thisObject.maxValue
coordinateSystem.recalculateScale()
}
}
if (isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined) {
saveObjectState()
return
}
coordinateSystem.min.y = code.minValue
coordinateSystem.max.y = code.maxValue
saveObjectState() // this overrides any invalid value at the config.
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
@@ -371,6 +364,14 @@ function newRateScale () {
thisObject.container.frame.position.y = ratePoint.y - thisObject.container.frame.height
thisObject.container.frame.position.x = ratePoint.x - thisObject.container.frame.width
thisObject.isVisible = true
if (thisObject.container.frame.position.y + thisObject.container.frame.height * 2 > bottonCorner.y ||
thisObject.container.frame.position.y - thisObject.container.frame.height * 1 < upCorner.y ||
thisObject.container.frame.position.x < upCorner.x
) {
thisObject.isVisible = false
}
}
function draw () {
@@ -392,8 +393,12 @@ function newRateScale () {
let rate = thisObject.rate
if (rate < coordinateSystem.min.y) { rate = coordinateSystem.min.y }
if (rate > coordinateSystem.max.y) { rate = coordinateSystem.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('.')
+11 -3
View File
@@ -6,6 +6,7 @@ function newTimeFrameScale () {
container: undefined,
fitFunction: undefined,
payload: undefined,
isVisible: true,
onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer,
draw: draw,
drawForeground: drawForeground,
@@ -32,7 +33,6 @@ function newTimeFrameScale () {
let onMouseOverEventSubscriptionId
let onMouseNotOverEventSubscriptionId
let coordinateSystem
let limitingContainer
let mouse = {
@@ -67,10 +67,12 @@ function newTimeFrameScale () {
thisObject.container = undefined
thisObject.fitFunction = undefined
thisObject.payload = undefined
limitingContainer = undefined
mouse = undefined
}
function initialize (pCoordinateSystem, pLimitingContainer) {
coordinateSystem = pCoordinateSystem
function initialize (pLimitingContainer) {
limitingContainer = pLimitingContainer
readObjectState()
@@ -175,6 +177,12 @@ function newTimeFrameScale () {
thisObject.container.frame.position.x = timePoint.x
thisObject.container.frame.position.y = timePoint.y - thisObject.container.frame.height
thisObject.isVisible = true
if (thisObject.container.frame.position.y + thisObject.container.frame.height > bottonCorner.y ||
thisObject.container.frame.position.y - thisObject.container.frame.height * 3 < upCorner.y) {
thisObject.isVisible = false
}
}
function onViewportZoomChanged (event) {
+49 -21
View File
@@ -7,6 +7,9 @@ function newTimeScale () {
date: undefined,
fitFunction: undefined,
payload: undefined,
isVisible: true,
fromDate: undefined,
toDate: undefined,
onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer,
physics: physics,
draw: draw,
@@ -71,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)
@@ -154,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.
}
@@ -165,28 +173,42 @@ 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 {
if (thisObject.fromDate !== Date.parse(code.fromDate) || thisObject.toDate !== Date.parse(code.toDate)) {
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.
}
@@ -244,6 +266,12 @@ function newTimeScale () {
thisObject.container.frame.position.x = timePoint.x
thisObject.container.frame.position.y = timePoint.y
thisObject.isVisible = true
if (thisObject.container.frame.position.y + thisObject.container.frame.height * 4 > bottonCorner.y ||
thisObject.container.frame.position.y < upCorner.y) {
thisObject.isVisible = false
}
}
function draw () {
+30 -14
View File
@@ -163,23 +163,39 @@ function newPanelsSpace () {
/* Lets see which quadrant the panel is at */
let verticalLine = (canvas.chartSpace.viewport.visibleArea.topRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2 + canvas.chartSpace.viewport.visibleArea.topLeft.x
let horizontalLine = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) * 2 / 3 + canvas.chartSpace.viewport.visibleArea.topRight.y
let horizontalLine = (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) / 2 + canvas.chartSpace.viewport.visibleArea.topRight.y
if (centerPoint.x < verticalLine && centerPoint.y < horizontalLine) {
panel.gravitatesTowards = 'topLeft'
}
if (centerPoint.x >= verticalLine && centerPoint.y < horizontalLine) {
panel.gravitatesTowards = 'topRight'
}
if (centerPoint.x < verticalLine && centerPoint.y >= horizontalLine) {
panel.gravitatesTowards = 'bottomLeft'
}
if (centerPoint.x >= verticalLine && centerPoint.y >= horizontalLine) {
panel.gravitatesTowards = 'bottomRight'
if (panel.panelTabButton !== undefined) {
if (panel.panelTabButton.status === 'up') {
if (centerPoint.x < verticalLine) {
panel.gravitatesTowards = 'topLeft'
} else {
panel.gravitatesTowards = 'topRight'
}
} else {
if (centerPoint.x < verticalLine) {
panel.gravitatesTowards = 'bottomLeft'
} else {
panel.gravitatesTowards = 'bottomRight'
}
}
} else {
if (centerPoint.x < verticalLine && centerPoint.y < horizontalLine) {
panel.gravitatesTowards = 'topLeft'
}
if (centerPoint.x >= verticalLine && centerPoint.y < horizontalLine) {
panel.gravitatesTowards = 'topRight'
}
if (centerPoint.x < verticalLine && centerPoint.y >= horizontalLine) {
panel.gravitatesTowards = 'bottomLeft'
}
if (centerPoint.x >= verticalLine && centerPoint.y >= horizontalLine) {
panel.gravitatesTowards = 'bottomRight'
}
}
/* According to the quadrant we push the panels to the sides */
if (centerPoint.x < verticalLine) {
if (panel.gravitatesTowards === 'topLeft' || panel.gravitatesTowards === 'bottomLeft') {
panel.container.frame.position.x = panel.container.frame.position.x - panel.container.speed.x
isOverlapping(i, panel.container)
if (panel.container.frame.position.x < 0) {
@@ -193,7 +209,7 @@ function newPanelsSpace () {
}
}
if (panel.container.frame.height <= canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topRight.y) {
if (centerPoint.y < horizontalLine) {
if (panel.gravitatesTowards === 'topLeft' || panel.gravitatesTowards === 'topRight') {
panel.container.frame.position.y = panel.container.frame.position.y - panel.container.speed.y
isOverlapping(i, panel.container)
if (panel.container.frame.position.y < canvas.chartSpace.viewport.visibleArea.topLeft.y) {
+1 -1
View File
@@ -125,7 +125,7 @@ function newSplashScreen () {
fontSize = 15
title = 'People and Machines working together to create Superalgos'
title = 'Beta'
titlePoint = {
x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20,
+15 -102
View File
@@ -26,7 +26,7 @@ function savePropertyAtNodeConfig (payload, propertyName, value) {
try {
let code = JSON.parse(payload.node.code)
code[propertyName] = value
payload.node.code = JSON.stringify(code)
payload.node.code = JSON.stringify(code, null, 4)
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
@@ -147,117 +147,30 @@ function getMilisecondsFromPoint (point, container, coordinateSystem) {
return point.x
}
function saveUserPosition (container, coordinateSystem, position) {
if (position === undefined) {
position = {
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
}
}
let userPosition = {
date: getDateFromPoint(position, container, coordinateSystem),
rate: getRateFromPoint(position, container, coordinateSystem),
market: DEFAULT_MARKET,
zoom: canvas.chartSpace.viewport.zoomTargetLevel
}
window.localStorage.setItem('userPosition', JSON.stringify(userPosition))
}
function getUserPosition (coordinateSystem) {
let savedPosition = window.localStorage.getItem('userPosition')
let userPosition
if (savedPosition === null) {
userPosition = {
date: (new Date()).toString(),
rate: coordinateSystem.max.y / 2,
market: DEFAULT_MARKET,
zoom: INITIAL_ZOOM_LEVEL
}
} else {
userPosition = JSON.parse(savedPosition)
}
userPosition.point = {
x: (new Date(userPosition.date)).valueOf(),
y: userPosition.rate
}
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) {
+20 -20
View File
@@ -22,9 +22,9 @@
],
"menuItems": [
{
"action": "Edit Plotter Module",
"action": "Config Plotter Module",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Plotter Module",
"label": "Config Plotter Module",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -151,9 +151,9 @@
],
"menuItems": [
{
"action": "Edit Plotter Panel",
"action": "Config Plotter Panel",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Plotter Panel",
"label": "Config Plotter Panel",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -208,9 +208,9 @@
],
"menuItems": [
{
"action": "Edit Panel Data",
"action": "Config Panel Data",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Panel Data",
"label": "Config Panel Data",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -1474,7 +1474,7 @@
"action": "Delete UI Object",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete Base Asset",
"label": "Delete Quoted Asset",
"iconPathOn": "delete",
"iconPathOff": "delete",
"actionFunction": "payload.onMenuItemClick"
@@ -4004,9 +4004,9 @@
},
"menuItems": [
{
"action": "Edit Telegram Bot",
"action": "Config Telegram Bot",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Telegram Bot",
"label": "Config Telegram Bot",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -4039,9 +4039,9 @@
},
"menuItems": [
{
"action": "Edit Announcement",
"action": "Config Announcement",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Announcement",
"label": "Config Announcement",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -4158,9 +4158,9 @@
"type": "Crypto Exchange",
"menuItems": [
{
"action": "Edit Crypto Exchange",
"action": "Config Crypto Exchange",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Crypto Exchange",
"label": "Config Crypto Exchange",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -4314,9 +4314,9 @@
"type": "Asset",
"menuItems": [
{
"action": "Edit Asset",
"action": "Config Asset",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Asset",
"label": "Config Asset",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -4466,9 +4466,9 @@
"actionFunction": "payload.onMenuItemClick"
},
{
"action": "Edit Market",
"action": "Config Market",
"actionFunction": "uiObject.configEditor.activate",
"label": "Edit Market",
"label": "Config Market",
"iconPathOn": "html",
"iconPathOff": "html"
},
@@ -4727,7 +4727,7 @@
}
],
"initialValues": {
"code": "{ \n\"codeName\": \"Paste your exchange API name or label here\",\n\"secret\": \"Paste your exchange API secret key here. Exchange keys are filtered out and NOT exported when using the SHARE menu option on any node at your workspace. Exchange keys ARE downloaded when using the DOWNLOAD button or the CLONE button.\"\n}"
"code": "{ \n\"codeName\": \"Paste your exchange API name or label here\",\n\"secret\": \"Paste your exchange API secret key here. To keep you exchange keys safe, never share data structures you may download from the system, as downloads contain all information in the data structure, including personal information such as exchange keys. Use the share option on the menu instead. The share option strips sensitive information and outputs a file that is safe for sharing.\"\n}"
},
"addLeftIcons": true,
"editors": {
@@ -4838,7 +4838,7 @@
}
],
"initialValues": {
"code": "{ \n\"product\": \"Type here the codeName of the Product\"\n}"
"code": "{}"
},
"addLeftIcons": true,
"editors": {
@@ -4935,7 +4935,7 @@
}
],
"initialValues": {
"code": "{ \n\"scale\": \"0.00\"\n}"
"code": "{ \n\"scale\": \"0.00\",\n\"fromDate\": \"2018-01-01\",\n\"toDate\": \"2020-12-31\"\n}"
},
"addLeftIcons": true,
"editors": {
@@ -17,6 +17,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
draw: draw,
recalculateScale: recalculateScale,
@@ -35,7 +36,7 @@
container.initialize();
thisObject.container = container;
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let timeFrame; // This will hold the current Time Frame the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -50,20 +51,23 @@
let bands = []; // Here we keep the bands to be ploted every time the Draw() function is called by the AAWebPlatform.
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -84,13 +88,16 @@
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -101,13 +108,13 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster.
recalculateScale();
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame);
@@ -120,13 +127,13 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
recalculate();
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculateScale();
recalculate();
})
@@ -138,6 +145,23 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function getContainer(point) {
try {
@@ -224,9 +248,13 @@
}
function setDatetime(pDatetime) {
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -329,7 +357,10 @@
band.standardDeviation = dailyFile[i][3];
band.deviation = dailyFile[i][4];
if (band.begin >= farLeftDate.valueOf() && band.end <= farRightDate.valueOf()) {
if (
(band.begin >= farLeftDate.valueOf() && band.end <= farRightDate.valueOf()) &&
(band.begin >= coordinateSystem.min.x && band.end <= coordinateSystem.max.x)
) {
bands.push(band);
@@ -404,7 +435,10 @@
band.standardDeviation = marketFile[i][3];
band.deviation = marketFile[i][4];
if (band.begin >= leftDate.valueOf() && band.end <= rightDate.valueOf()) {
if (
(band.begin >= leftDate.valueOf() && band.end <= rightDate.valueOf()) &&
(band.begin >= coordinateSystem.min.x && band.end <= coordinateSystem.max.x)
) {
bands.push(band);
@@ -457,9 +491,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
let band;
let previousBand;
@@ -17,6 +17,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
draw: draw,
recalculateScale: recalculateScale,
@@ -34,7 +35,7 @@
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let timeFrame; // This will hold the current Time Frame the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -49,20 +50,23 @@
let candles = []; // Here we keep the candles to be ploted every time the Draw() function is called by the AAWebPlatform.
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -82,13 +86,16 @@
fileCursor = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -99,13 +106,13 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster.
recalculateScale();
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame);
@@ -118,13 +125,13 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
recalculate();
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculateScale()
recalculate();
})
@@ -136,6 +143,23 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function getContainer(point) {
try {
@@ -214,9 +238,13 @@
}
function setDatetime(pDatetime) {
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -330,7 +358,11 @@
if (candle.open < candle.close) { candle.direction = 'up'; }
if (candle.open === candle.close) { candle.direction = 'side'; }
if (candle.begin >= farLeftDate.valueOf() && candle.end <= farRightDate.valueOf()) {
if (
(candle.begin >= farLeftDate.valueOf() && candle.end <= farRightDate.valueOf()) &&
(candle.begin >= coordinateSystem.min.x && candle.end <= coordinateSystem.max.x)
) {
candles.push(candle);
@@ -406,7 +438,11 @@
if (candle.open < candle.close) { candle.direction = 'up'; }
if (candle.open === candle.close) { candle.direction = 'side'; }
if (candle.begin >= leftDate.valueOf() && candle.end <= rightDate.valueOf()) {
if (
(candle.begin >= leftDate.valueOf() && candle.end <= rightDate.valueOf()) &&
(candle.begin >= coordinateSystem.min.x && candle.end <= coordinateSystem.max.x)
)
{
candles.push(candle);
@@ -459,9 +495,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
if (candles.length > 0) {
/* Now we calculate all the points. */
@@ -21,6 +21,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
recalculateScale: recalculateScale,
draw: draw
};
@@ -30,7 +31,7 @@
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let plotAreaFrame = newCoordinateSystem(); // This chart uses this extra object.
let timeFrame; // This will hold the current Time Frame the user is at.
@@ -48,20 +49,23 @@
let volumes = []; // Here we keep the volumes to be ploted every time the Draw() function is called by the AAWebPlatform.
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -81,13 +85,16 @@
fileCursor = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -98,6 +105,8 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
@@ -115,6 +124,7 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
@@ -136,6 +146,25 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculateScaleX();
recalculate();
recalculateScaleY();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function recalculateScale() {
recalculateScaleX();
@@ -234,9 +263,13 @@
}
function setDatetime(pDatetime) {
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -340,7 +373,10 @@
volume.begin = dailyFile[i][2];
volume.end = dailyFile[i][3];
if (volume.begin >= farLeftDate.valueOf() && volume.end <= farRightDate.valueOf()) {
if (
(volume.begin >= farLeftDate.valueOf() && volume.end <= farRightDate.valueOf()) &&
(volume.begin >= coordinateSystem.min.x && volume.end <= coordinateSystem.max.x)
) {
volumes.push(volume);
@@ -411,7 +447,10 @@
volume.begin = marketFile[i][2];
volume.end = marketFile[i][3];
if (volume.begin >= leftDate.valueOf() && volume.end <= rightDate.valueOf()) {
if (
(volume.begin >= leftDate.valueOf() && volume.end <= rightDate.valueOf()) &&
(volume.begin >= coordinateSystem.min.x && volume.end <= coordinateSystem.max.x)
) {
volumes.push(volume);
@@ -516,9 +555,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
if (volumes.length > 0) {
/* Now we calculate and plot the volumes */
@@ -21,6 +21,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
recalculateScale: recalculateScale,
draw: draw,
@@ -35,7 +36,7 @@
container.initialize();
thisObject.container = container;
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let timeFrame; // This will hold the current Time Frame the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -50,20 +51,23 @@
let stairsArray = []; // Here we keep the candle-stairs to be ploted every time the Draw() function is called by the AAWebPlatform.
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -83,13 +87,16 @@
fileCursor = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err.message = " + err.message); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -100,13 +107,13 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster.
recalculateScale();
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame);
@@ -119,13 +126,13 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
recalculate();
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculateScale()
recalculate();
})
@@ -139,6 +146,23 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function getContainer(point) {
try {
@@ -227,9 +251,13 @@
}
function setDatetime(pDatetime) {
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -356,7 +384,10 @@
stairs.lastMin = dailyFile[i][10];
stairs.lastMax = dailyFile[i][11];
if (stairs.begin >= farLeftDate.valueOf() && stairs.end <= farRightDate.valueOf()) {
if (
(stairs.begin >= farLeftDate.valueOf() && stairs.end <= farRightDate.valueOf()) &&
(stairs.begin >= coordinateSystem.min.x && stairs.end <= coordinateSystem.max.x)
) {
stairsArray.push(stairs);
@@ -449,7 +480,10 @@
stairs.lastMin = marketFile[i][10];
stairs.lastMax = marketFile[i][11];
if (stairs.begin >= leftDate.valueOf() && stairs.end <= rightDate.valueOf()) {
if (
(stairs.begin >= leftDate.valueOf() && stairs.end <= rightDate.valueOf()) &&
(stairs.begin >= coordinateSystem.min.x && stairs.end <= coordinateSystem.max.x)
) {
stairsArray.push(stairs);
@@ -504,9 +538,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
if (stairsArray.length > 0) {
for (var i = 0; i < stairsArray.length; i++) {
@@ -21,6 +21,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
recalculateScale: recalculateScale,
draw: draw
};
@@ -31,7 +32,7 @@
container.initialize();
thisObject.container = container;
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let coordinateSystemFrame = newCoordinateSystem(); // This chart uses this extra object.
let timeFrame; // This will hold the current Time Frame the user is at.
@@ -49,20 +50,23 @@
let stairsArray = []; // Here we keep the stairsArray to be ploted every time the Draw() function is called by the AAWebPlatform.
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -82,13 +86,16 @@
fileCursor = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err.message = " + err.message); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -99,6 +106,8 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
@@ -116,6 +125,7 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
@@ -139,6 +149,25 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculateScaleX();
recalculate();
recalculateScaleY();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function recalculateScale() {
recalculateScaleX();
@@ -235,9 +264,13 @@
}
function setDatetime(pDatetime) {
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -353,7 +386,10 @@
stairs.firstAmount = dailyFile[i][5];
stairs.lastAmount = dailyFile[i][6];
if (stairs.begin >= farLeftDate.valueOf() && stairs.end <= farRightDate.valueOf()) {
if (
(stairs.begin >= farLeftDate.valueOf() && stairs.end <= farRightDate.valueOf()) &&
(stairs.begin >= coordinateSystem.min.x && stairs.end <= coordinateSystem.max.x)
) {
stairsArray.push(stairs);
@@ -434,7 +470,10 @@
stairs.firstAmount = marketFile[i][5];
stairs.lastAmount = marketFile[i][6];
if (stairs.begin >= leftDate.valueOf() && stairs.end <= rightDate.valueOf()) {
if (
(stairs.begin >= leftDate.valueOf() && stairs.end <= rightDate.valueOf()) &&
(stairs.begin >= coordinateSystem.min.x && stairs.end <= coordinateSystem.max.x)
) {
stairsArray.push(stairs);
@@ -549,9 +588,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
let opacity = '0.25';
let visibleHeight = canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y;
@@ -17,6 +17,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
recalculateScale: recalculateScale,
draw: draw
};
@@ -27,7 +28,7 @@
container.initialize();
thisObject.container = container;
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let timeFrame; // This will hold the current Time Frame the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -40,17 +41,20 @@
let previousNotesSetKey;
let onMouseOverEventSuscriptionId
let offsetChangedEventSubscriptionId
let filesUpdatedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
fileSequence.eventHandler.stopListening(filesUpdatedEventSubscriptionId);
thisObject.container.eventHandler.stopListening(dimmensionsChangedEventSubscriptionId)
@@ -65,31 +69,35 @@
plotLines = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] ' + MODULE_NAME + ' -> finalize -> err = " + err.stack.stack); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
fileSequence = pStorage.fileSequences[0];
recalculate();
recalculateScale();
filesUpdatedEventSubscriptionId = fileSequence.eventHandler.listenToEvent("Files Updated", onFilesUpdated); // Only the first sequence is supported right now.
offsetChangedEventSubscriptionId = canvas.chartSpace.viewport.eventHandler.listenToEvent("Position Changed", onViewportPositionChanged);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Ready for when dimmension changes. */
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculate();
recalculateScale();
})
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
@@ -99,6 +107,23 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function getContainer(point) {
try {
let container;
@@ -123,8 +148,14 @@
recalculate();
}
function setDatetime(newDatetime) {
datetime = newDatetime;
function setDatetime(pDatetime) {
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onViewportPositionChanged() {
@@ -341,8 +372,6 @@
function plotChart() {
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
let currentRecord
let point = {
@@ -18,6 +18,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
draw: draw,
recalculateScale: recalculateScale,
@@ -36,7 +37,7 @@
container.initialize();
thisObject.container = container;
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let timeFrame; // This will hold the current Time Frame the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -52,13 +53,16 @@
let strategies = [];
let strategyImages = [];
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
@@ -67,7 +71,7 @@
if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); }
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -89,13 +93,16 @@
strategyImages = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -108,13 +115,13 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster.
recalculateScale();
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame);
@@ -127,6 +134,7 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
@@ -135,7 +143,6 @@
/* Ready for when dimmension changes. */
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculateScale()
recalculate();
})
@@ -152,6 +159,23 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function getContainer(point) {
try {
@@ -234,11 +258,13 @@
}
function setDatetime(pDatetime) {
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -359,7 +385,10 @@
record.beginRate = dailyFile[i][4];
record.endRate = dailyFile[i][5];
if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) {
if (
(record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
strategies.push(record);
@@ -431,7 +460,10 @@
strategies.push(record);
if (datetime.valueOf() >= record.begin && datetime.valueOf() <= record.end) {
if (
(record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
thisObject.currentRecord = record;
thisObject.container.eventHandler.raiseEvent("Current Strategy Changed", thisObject.currentRecord);
@@ -482,9 +514,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
thisObject.container.eventHandler.raiseEvent("Current Strategy Record Changed", undefined);
let record;
@@ -18,6 +18,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
draw: draw,
recalculateScale: recalculateScale,
@@ -36,7 +37,7 @@
container.initialize();
thisObject.container = container;
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let timeFrame; // This will hold the current Time Frame the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -52,13 +53,16 @@
let trades = [];
let headers;
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
@@ -67,7 +71,7 @@
if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); }
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -87,13 +91,16 @@
fileCursor = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -106,13 +113,13 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster.
recalculateScale();
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame);
@@ -125,6 +132,7 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
@@ -133,7 +141,6 @@
/* Ready for when dimmension changes. */
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculateScale()
recalculate();
})
@@ -145,6 +152,23 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function getContainer(point) {
try {
@@ -227,11 +251,13 @@
}
function setDatetime(pDatetime) {
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -346,7 +372,10 @@
record.endRate = dailyFile[i][5];
record.exitType = dailyFile[i][6];
if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) {
if (
(record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
trades.push(record);
@@ -408,7 +437,10 @@
record.endRate = marketFile[i][5];
record.exitType = marketFile[i][6];
if (record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) {
if (
(record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
trades.push(record);
@@ -463,9 +495,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
thisObject.container.eventHandler.raiseEvent("Current Trade Record Changed", undefined);
let record;
@@ -17,6 +17,7 @@
getContainer: getContainer,
setTimeFrame: setTimeFrame,
setDatetime: setDatetime,
setCoordinateSystem: setCoordinateSystem,
draw: draw,
recalculateScale: recalculateScale,
@@ -35,7 +36,7 @@
container.initialize();
thisObject.container = container;
let coordinateSystem = newCoordinateSystem(); // Needed to be able to plot on the timeline, otherwise not.
let coordinateSystem
let timeFrame; // This will hold the current Time Frame the user is at.
let datetime; // This will hold the current Datetime the user is at.
@@ -54,20 +55,23 @@
let imageTakeProfitPhase;
let imageRecord;
let onMouseOverEventSuscriptionId
let zoomChangedEventSubscriptionId
let offsetChangedEventSubscriptionId
let dragFinishedEventSubscriptionId
let dimmensionsChangedEventSubscriptionId
let marketFilesUpdatedEventSubscriptionId
let dailyFilesUpdatedEventSubscriptionId
let scaleChangedEventSubscriptionId
let userPositionDate
return thisObject;
function finalize() {
try {
/* Stop listening to the necesary events. */
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
canvas.chartSpace.viewport.eventHandler.stopListening(zoomChangedEventSubscriptionId);
canvas.chartSpace.viewport.eventHandler.stopListening(offsetChangedEventSubscriptionId);
canvas.eventHandler.stopListening(dragFinishedEventSubscriptionId);
@@ -93,13 +97,16 @@
fileCursor = undefined;
thisObject.fitFunction = undefined
finalizeCoordinateSystem()
coordinateSystem = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err.stack); }
}
}
function initialize(pStorage, pDatetime, pTimeFrame, callBackFunction) {
function initialize(pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction) {
try {
@@ -110,13 +117,13 @@
datetime = pDatetime;
timeFrame = pTimeFrame;
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
/* We need a Market File in order to calculate the Y scale, since this scale depends on actual data. */
marketFile = marketFiles.getFile(ONE_DAY_IN_MILISECONDS); // This file is the one processed faster.
recalculateScale();
/* Now we set the right files according to current Period. */
marketFile = marketFiles.getFile(pTimeFrame);
@@ -129,6 +136,7 @@
dragFinishedEventSubscriptionId = canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
marketFilesUpdatedEventSubscriptionId = marketFiles.eventHandler.listenToEvent("Files Updated", onMarketFilesUpdated);
dailyFilesUpdatedEventSubscriptionId = dailyFiles.eventHandler.listenToEvent("Files Updated", onDailyFilesUpdated);
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
/* Get ready for plotting. */
@@ -137,7 +145,6 @@
/* Ready for when dimmension changes. */
dimmensionsChangedEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('Dimmensions Changed', function () {
recalculateScale()
recalculate();
})
@@ -155,6 +162,23 @@
}
}
function initializeCoordinateSystem() {
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
}
function finalizeCoordinateSystem() {
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
}
function onScaleChanged() {
recalculate();
}
function onMouseOver(event) {
let userPosition = getDateFromPoint(event, thisObject.container, coordinateSystem)
userPositionDate = userPosition.valueOf()
}
function getContainer(point) {
let container;
/* First we check if this point is inside this space. */
@@ -221,9 +245,13 @@
}
function setDatetime(pDatetime) {
datetime = pDatetime;
}
function setCoordinateSystem(pCoordinateSystem) {
finalizeCoordinateSystem()
coordinateSystem = pCoordinateSystem
initializeCoordinateSystem()
}
function onDailyFileLoaded(event) {
@@ -360,7 +388,10 @@
record.positionPeriods = dailyFile[i][34];
record.positionDays = dailyFile[i][35];
if (record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) {
if (
(record.begin >= farLeftDate.valueOf() && record.end <= farRightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
records.push(record);
@@ -448,7 +479,10 @@
record.positionPeriods = marketFile[i][34];
record.positionDays = marketFile[i][35];
if (record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) {
if (
(record.begin >= leftDate.valueOf() && record.end <= rightDate.valueOf()) &&
(record.begin >= coordinateSystem.min.x && record.end <= coordinateSystem.max.x)
) {
records.push(record);
@@ -502,9 +536,6 @@
try {
let userPosition = getUserPosition()
let userPositionDate = userPosition.point.x
let record;
/* Now we calculate and plot the records */
+1 -1
View File
@@ -1 +1 @@
{"type":"Workspace","name":"Bot Instance Config Cleaned","rootNodes":[{"type":"Network","name":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","dataStorage":{"type":"Data Storage","name":"New Data Storage","sessionIndependentData":{"type":"Session Independent Data","name":"New Session Independent Data","singleMarketData":[{"type":"Single Market Data","name":"Poloniex BTC/USDT","dataProducts":[{"type":"Data Product","name":"Candles","id":"55e735a5-60c9-4e2d-a582-a6c6eddf3502","savedPayload":{"position":{"x":20638.6059442939,"y":26942.27818712573},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Candles","id":"36ae2d5d-6734-4526-b2f8-31c89a0c4fc1"}}},{"type":"Data Product","name":"Volumes","id":"ffaf5a8e-12d6-4040-922d-57845eb3377c","savedPayload":{"position":{"x":20804.619211464753,"y":26745.34536940477},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Volumes","id":"b2d5ba69-67ac-490f-9e74-28239b35a92e"}}},{"type":"Data Product","name":"Candle-Stairs","id":"e1c46e1f-09d1-46a2-b738-e761b4e04cd9","savedPayload":{"position":{"x":21022.09028220901,"y":26879.455513120673},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Candle-Stairs","id":"642474e9-da61-4168-97dc-7f7869bebc02"}}},{"type":"Data Product","name":"Volume-Stairs","id":"eefaf182-ffe4-457e-a7fa-f43dfabdc086","savedPayload":{"position":{"x":21289.6777141654,"y":27102.547956317398},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Volume-Stairs","id":"846e9572-c4d6-4c7e-942e-c82402c5ecea"}}},{"type":"Data Product","name":"Bollinger Bands","id":"3576cfd0-1774-4094-b8a0-66e182fc4c41","savedPayload":{"position":{"x":21200.510975971047,"y":27469.85063353425},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Bollinger Bands","id":"29088877-8d63-4217-8d34-8742afc262f4"}}},{"type":"Data Product","name":"Percentage Bandwidth","id":"4dfde44c-0bbf-4204-91de-ce99ecba4cf2","savedPayload":{"position":{"x":20895.702155757215,"y":27778.625205637927},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Percentage Bandwidth","id":"3b7885a0-cd72-4a3f-a38b-3dc8c47bd068"}}},{"type":"Data Product","name":"Bollinger Channels Objects","id":"6986bcb1-119c-48c9-a00b-d046e9e07951","savedPayload":{"position":{"x":20411.34568682323,"y":27774.338383921255},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Bollinger Channels Objects","id":"1f111f72-624f-4166-9f99-ab8d785d5267"}}},{"type":"Data Product","name":"Bollinger Sub-Channels Objects","id":"85098ab8-a125-49f1-b24d-416c2090c7a0","savedPayload":{"position":{"x":20386.252015593775,"y":27274.154501298886},"targetPosition":{"x":20753.26730568965,"y":27123.76805855528},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Bollinger Sub-Channels Objects","id":"080c87fc-4546-4482-ab11-180a33f6d9ab"}}}],"id":"49a747b4-2eb7-41d6-b0e2-493f43ceed44","savedPayload":{"position":{"x":20753.27323415736,"y":27123.69839359708},"targetPosition":{"x":20294.58757634718,"y":26977.27809593435},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Market","name":"BTC/USDT","id":"d4098b73-7e25-434e-8fd9-342393cbb400"}}},{"type":"Single Market Data","name":"Kraken ETH/BTC","dataProducts":[{"type":"Data Product","name":"Candles","id":"fce50098-d674-4006-94ad-cce46f3d59a4","savedPayload":{"position":{"x":20749.113604244125,"y":27179.829098890244},"targetPosition":{"x":20390.125134675498,"y":27162.662207172078},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Candles","id":"36ae2d5d-6734-4526-b2f8-31c89a0c4fc1"}}},{"type":"Data Product","name":"Volumes","id":"601b3615-7045-4e8f-aaaLine truncated
{"type":"Workspace","name":"Bot Instance Config Cleaned","rootNodes":[{"type":"Network","name":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","dataStorage":{"type":"Data Storage","name":"New Data Storage","sessionIndependentData":{"type":"Session Independent Data","name":"New Session Independent Data","singleMarketData":[{"type":"Single Market Data","name":"Poloniex BTC/USDT","dataProducts":[{"type":"Data Product","name":"Candles","id":"55e735a5-60c9-4e2d-a582-a6c6eddf3502","savedPayload":{"position":{"x":20623.359998665186,"y":26939.971257636924},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Candles","id":"36ae2d5d-6734-4526-b2f8-31c89a0c4fc1"}}},{"type":"Data Product","name":"Volumes","id":"ffaf5a8e-12d6-4040-922d-57845eb3377c","savedPayload":{"position":{"x":20812.723461038408,"y":26725.760340082204},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Volumes","id":"b2d5ba69-67ac-490f-9e74-28239b35a92e"}}},{"type":"Data Product","name":"Candle-Stairs","id":"e1c46e1f-09d1-46a2-b738-e761b4e04cd9","savedPayload":{"position":{"x":21056.642323957538,"y":26874.97718532498},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Candle-Stairs","id":"642474e9-da61-4168-97dc-7f7869bebc02"}}},{"type":"Data Product","name":"Volume-Stairs","id":"eefaf182-ffe4-457e-a7fa-f43dfabdc086","savedPayload":{"position":{"x":21306.422962820903,"y":27127.03740727769},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Volume-Stairs","id":"846e9572-c4d6-4c7e-942e-c82402c5ecea"}}},{"type":"Data Product","name":"Bollinger Bands","id":"3576cfd0-1774-4094-b8a0-66e182fc4c41","savedPayload":{"position":{"x":21204.491485674356,"y":27496.421215303384},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Bollinger Bands","id":"29088877-8d63-4217-8d34-8742afc262f4"}}},{"type":"Data Product","name":"Percentage Bandwidth","id":"4dfde44c-0bbf-4204-91de-ce99ecba4cf2","savedPayload":{"position":{"x":20888.624115719744,"y":27761.761912702594},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Percentage Bandwidth","id":"3b7885a0-cd72-4a3f-a38b-3dc8c47bd068"}}},{"type":"Data Product","name":"Bollinger Channels Objects","id":"6986bcb1-119c-48c9-a00b-d046e9e07951","savedPayload":{"position":{"x":20413.198693352406,"y":27799.775805452602},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Bollinger Channels Objects","id":"1f111f72-624f-4166-9f99-ab8d785d5267"}}},{"type":"Data Product","name":"Bollinger Sub-Channels Objects","id":"85098ab8-a125-49f1-b24d-416c2090c7a0","savedPayload":{"position":{"x":20393.1740350247,"y":27297.229724766323},"targetPosition":{"x":20755.378605069884,"y":27148.60619994661},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Bollinger Sub-Channels Objects","id":"080c87fc-4546-4482-ab11-180a33f6d9ab"}}}],"id":"49a747b4-2eb7-41d6-b0e2-493f43ceed44","savedPayload":{"position":{"x":20755.458524955015,"y":27148.309419015524},"targetPosition":{"x":20266.035725318918,"y":26991.464061300452},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Market","name":"BTC/USDT","id":"d4098b73-7e25-434e-8fd9-342393cbb400"}}},{"type":"Single Market Data","name":"Kraken ETH/BTC","dataProducts":[{"type":"Data Product","name":"Candles","id":"fce50098-d674-4006-94ad-cce46f3d59a4","savedPayload":{"position":{"x":20729.46923054578,"y":27147.49074220674},"targetPosition":{"x":20335.978159785296,"y":27128.593324095094},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"isTensed":true},"uiObject":{},"referenceParent":{"type":"Product Definition","name":"Candles","id":"36ae2d5d-6734-4526-b2f8-31c89a0c4fc1"}}},{"type":"Data Product","name":"Volumes","id":"601b361Line truncated
+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Superalgos Desktop App</title>
<title>Superalgos</title>
<meta name="description"
content="The system enabling a collective of humans and machines to collaborate and compete while co-building trading algorithms.">
<meta http-equiv="x-ua-compatible" content="ie=edge">