From d5cd77e6558922cdbe5bcf5ae939252e4bb25ee5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 9 Oct 2020 13:17:41 +0200 Subject: [PATCH] Update Plotter.js --- CanvasApp/Plotting/Plotter.js | 53 ++++++++++------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/CanvasApp/Plotting/Plotter.js b/CanvasApp/Plotting/Plotter.js index 91a276da1..365faaea2 100644 --- a/CanvasApp/Plotting/Plotter.js +++ b/CanvasApp/Plotting/Plotter.js @@ -293,18 +293,20 @@ function newPlotter() { record.index = dataFile[i][recordDefinition.properties.length] } - 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 - - if (record.begin === undefined || record.end === undefined) { - console.log('Could not find the property begin or end which are needed for the plotter to work. productDefinition.config.codeName = ' + productDefinition.config.codeName) - } + if (record.begin === undefined || record.end === undefined) { + console.log('Could not find the property begin or end which are needed for the plotter to work. productDefinition.config.codeName = ' + productDefinition.config.codeName) + continue } + + if (record.end <= farLeftDate.valueOf()) { continue } + if (record.begin >= farRightDate.valueOf()) { continue } + + if (record.end < coordinateSystem.min.x) { continue } + if (record.begin > coordinateSystem.max.x) { continue } + + record.previous = previous + jsonifiedArray.push(record) + previous = record } return jsonifiedArray @@ -471,31 +473,6 @@ function newPlotter() { } } - function recalculateScale() { - try { - if (coordinateSystem.maxValue > 0) { return } // Already calculated. - /* First we calculate the default scale */ - let minValue = { - x: MIN_PLOTABLE_DATE.valueOf(), - y: 0 - } - - let maxValue = { - x: MAX_PLOTABLE_DATE.valueOf(), - y: nextPorwerOf10(MAX_DEFAULT_RATE_SCALE_VALUE) / 4 // TODO: This 4 is temporary - } - - coordinateSystem.initialize( - minValue, - maxValue, - thisObject.container.frame.width, - thisObject.container.frame.height - ) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] recalculateScale -> err = ' + err.stack) } - } - } - function plot() { try { /* Clean the pannel at places where there is no record. */ @@ -588,7 +565,7 @@ function newPlotter() { The information we store in files is independent from the charing system and its coordinate systems. That means that the first thing we allways need to do is to trasform these points to the coordinate system of the timeline. */ - let dataPoint + let dataPoint dataPoint = coordinateSystem.transformThisPoint(rawPoint) dataPoint = transformThisPoint(dataPoint, thisObject.container) let testPoint = { @@ -764,7 +741,7 @@ function newPlotter() { It can happen that objects that span through a long period of time could have its begin point inside the visible viewport but not its end point. In those cases, the end point should not be reported. */ - + if (dataPointObject.rawPoint.y > 1 && dataPointObject.rawPoint.y !== undefined && isNaN(dataPointObject.rawPoint.y) === false) { let rawPoint = coordinateSystem.transformThisPoint(dataPointObject.rawPoint) if (dataPointObject.isInViewPort === true) {