diff --git a/Globals.js b/Globals.js index 61cd669b2..44cb0d68b 100644 --- a/Globals.js +++ b/Globals.js @@ -143,7 +143,14 @@ const _3_MINUTES_IN_MILISECONDS = 3 * 60 * 1000; const _2_MINUTES_IN_MILISECONDS = 2 * 60 * 1000; const _1_MINUTE_IN_MILISECONDS = 1 * 60 * 1000; -const EARLIEST_DATE = new Date(2014, 0, 18, 4, 26, 8); +let NEW_SESSION_INITIAL_DATE = new Date(); // This value will be overwritten at the viewPort.initialize if the user had a prevous session with this same browser. + +let maxDate = new Date(); +maxDate.setMilliseconds(0); +maxDate.setDate(maxDate.getDate() + 365 * 4); // We might have charts that projects data into the future. + +const MIN_PLOTABLE_DATE = new Date(2015, 0, 1, 0, 0, 0); +const MAX_PLOTABLE_DATE = maxDate; const TOP_SPACE_HEIGHT = 5; const BOTTOM_SPACE_HEIGHT = 35; @@ -167,13 +174,9 @@ const PERIOD_10_MIN = "10-min"; const PERIOD_05_MIN = "05-min"; const PERIOD_01_MIN = "01-min"; -let INITIAL_DATE = new Date(); // This value will be overwritten at the viewPort.initialize if the user had a prevous session with this same browser. -var maxDate = new Date(); -maxDate.setMilliseconds(0); -maxDate.setDate(maxDate.getDate() + 10); -const MAX_PLOTABLE_DATE = maxDate; + /* We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space. diff --git a/Panels/TimeControlPanel.js b/Panels/TimeControlPanel.js index 2a1448e4e..b56759dc3 100644 --- a/Panels/TimeControlPanel.js +++ b/Panels/TimeControlPanel.js @@ -37,7 +37,7 @@ function newTimeControlPanel () { panelTabButton.container.frame.parentFrame = thisObject.container.frame panelTabButton.initialize() - let datetime = INITIAL_DATE + let datetime = NEW_SESSION_INITIAL_DATE let datetimeDisplay = { currentDatetime: datetime, diff --git a/PlottersManager.js b/PlottersManager.js index b73fbc704..f868af859 100644 --- a/PlottersManager.js +++ b/PlottersManager.js @@ -10,7 +10,7 @@ function newPlottersManager () { let competitionPlotters = [] let timePeriod = INITIAL_TIME_PERIOD - let datetime = INITIAL_DATE + let datetime = NEW_SESSION_INITIAL_DATE let thisObject = { setDatetime: setDatetime, @@ -476,7 +476,7 @@ function newPlottersManager () { if (INFO_LOG === true) { logger.write('[INFO] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> key = ' + pProductCard.product.plotter.devTeam + '-' + pProductCard.product.plotter.codeName + '-' + pProductCard.product.plotter.moduleName) } try { - // plotter.positionAtDatetime(INITIAL_DATE); + // plotter.positionAtDatetime(NEW_SESSION_INITIAL_DATE); } catch (err) { // If the plotter does not implement this function its ok. } diff --git a/ProductCard.js b/ProductCard.js index 0dcdbd59c..15bdff06a 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -70,7 +70,7 @@ function newProductCard () { } let timePeriod = INITIAL_TIME_PERIOD - let datetime = INITIAL_DATE + let datetime = NEW_SESSION_INITIAL_DATE /* TODO We are in a transition period in which bots and teams images might be located at different places. What we are going to do then is to try to load them from both places and use the variable that finally gets an diff --git a/TimeMachine.js b/TimeMachine.js index d046453af..ccc32f14f 100644 --- a/TimeMachine.js +++ b/TimeMachine.js @@ -204,6 +204,8 @@ function newTimeMachine () { if (timeScale !== undefined) { timeScale.draw() } if (rigthScale !== undefined) { rigthScale.draw() } + + thisObject.container.frame.draw(false, true, false) } function getContainer (point, purpose) { @@ -242,7 +244,7 @@ function newTimeMachine () { if (INFO_LOG === true) { logger.write('[INFO] recalculateScale -> Entering function.') } let minValue = { - x: EARLIEST_DATE.valueOf(), + x: MIN_PLOTABLE_DATE.valueOf(), y: 0 } diff --git a/TimelineChart.js b/TimelineChart.js index 551d1f2a5..615a378d2 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -9,7 +9,7 @@ let timeLineCoordinateSystem let timePeriod = INITIAL_TIME_PERIOD - let datetime = INITIAL_DATE + let datetime = NEW_SESSION_INITIAL_DATE let thisObject = { setDatetime: setDatetime, @@ -120,7 +120,7 @@ moveToUserPosition(thisObject.container, timeLineCoordinateSystem) timePeriod = INITIAL_TIME_PERIOD - datetime = INITIAL_DATE + datetime = NEW_SESSION_INITIAL_DATE /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ diff --git a/Utilities.js b/Utilities.js index 2ea30bde1..64156b30b 100644 --- a/Utilities.js +++ b/Utilities.js @@ -105,7 +105,7 @@ function moveToUserPosition (container, timeLineCoordinateSystem, ignoreX, ignor viewPort.newZoomLevel(userPosition.zoom) INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom) - INITIAL_DATE = new Date(userPosition.date) + NEW_SESSION_INITIAL_DATE = new Date(userPosition.date) let targetPoint = { x: (new Date(userPosition.date)).valueOf(), @@ -150,4 +150,3 @@ function removeTime (datetime) { return dateOnly } -