From cffeb5c16ad5fb2859ba6aafb0f47426c603be5f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 12 Feb 2020 21:53:39 +0100 Subject: [PATCH] Bug Fixes --- ChartsSpace/TimelineChart.js | 56 ++++++++++++++++++------------------ Globals.js | 2 +- Scales/RateScale.js | 3 ++ 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 5bed029e2..81ae1e2d0 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -63,7 +63,7 @@ function newTimelineChart () { } function finalize () { - coordinateSystem.eventHandler.stopListening(timelineChartCoordinateSystem) + coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId) if (thisObject.layersManager !== undefined) { finalizeLayersManager() @@ -131,8 +131,8 @@ function newTimelineChart () { /* Resets the local container with the dimessions of its parent, the Time Machine */ thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.height = TIME_MACHINE_HEIGHT - thisObject.container.frame.width = TIME_MACHINE_WIDTH + thisObject.container.frame.height = thisObject.container.parentContainer.frame.height + thisObject.container.frame.width = thisObject.container.parentContainer.frame.width } function initialize (pTimeMachineCoordinateSystem) { @@ -140,7 +140,7 @@ function newTimelineChart () { timeMachineCoordinateSystem = pTimeMachineCoordinateSystem coordinateSystem = timeMachineCoordinateSystem - onScaleChanged() + initializeCoordinateSystem() timeFrame = INITIAL_TIME_PERIOD @@ -149,6 +149,30 @@ function newTimelineChart () { scaleChangedEventSubscriptionId = timeMachineCoordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged) } + function initializeCoordinateSystem () { + let minValue = { + x: timeMachineCoordinateSystem.min.x, + y: 0 + } + + let maxValue = { + x: timeMachineCoordinateSystem.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, + thisObject.container.frame.width, + thisObject.container.frame.height + ) + } + function initializeLayersManager () { let owner = thisObject.payload.node.payload.parentNode.id // The real owner is the Time Machine layersPanelHandle = canvas.panelsSpace.createNewPanel('Layers Panel', undefined, owner) @@ -377,28 +401,4 @@ function newTimelineChart () { function drawChartsBackground () { drawContainerBackground(thisObject.container, UI_COLOR.WHITE, 0, thisObject.fitFunction) } - - function recalculateCoordinateSystem () { - let minValue = { - x: timelineChartCoordinateSystem.min.x, - y: 0 - } - - let maxValue = { - 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, - thisObject.container.frame.width, - thisObject.container.frame.height - ) - } } diff --git a/Globals.js b/Globals.js index 771fecd62..8ec77286f 100644 --- a/Globals.js +++ b/Globals.js @@ -209,7 +209,7 @@ We define here the size of the chartSpace. It has to bee enough big in order to */ const TIME_MACHINE_WIDTH = 250; -const TIME_MACHINE_HEIGHT = 250 / 50; +const TIME_MACHINE_HEIGHT = 50; let mediaRecorder // to downloadText canvas animation as a mediaRecorder let areWeRecording = false diff --git a/Scales/RateScale.js b/Scales/RateScale.js index dfecbec10..228dd2c5f 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -342,6 +342,8 @@ function newRateScale () { function drawScaleBox () { if (thisObject.rate === undefined) { return } + if (thisObject.payload === undefined) { return } + if (thisObject.payload.node === undefined) { return } let rate = thisObject.rate @@ -357,6 +359,7 @@ function newRateScale () { let label1 = thisObject.payload.node.payload.parentNode.name let label2 = (Math.trunc(rate)).toLocaleString() let label3 = labelArray[1] + if (label3 === undefined) { label3 = '00' } let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type) let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type)