From 66f853a305ef20b462b22ae495b067b39f757148 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 12 Dec 2019 18:11:37 +0100 Subject: [PATCH] Multiples Chart Points (array) --- .../FunctionLibraries/ChainAttachDetach.js | 7 ++- Plotter.js | 61 ++++++++++--------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index 19bb15465..557e44e1c 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -1163,10 +1163,11 @@ function newChainAttachDetach () { } break case 'array': { - let nodePropertyArray = node.payload.parentNode[property.name] - if (nodePropertyArray !== undefined) { - nodePropertyArray.push(node) + if (node.payload.parentNode[property.name] === undefined) { + node.payload.parentNode[property.name] = [] } + let nodePropertyArray = node.payload.parentNode[property.name] + nodePropertyArray.push(node) } break } diff --git a/Plotter.js b/Plotter.js index 58390e36e..405ac7c84 100644 --- a/Plotter.js +++ b/Plotter.js @@ -532,40 +532,43 @@ function newPlotter () { dataPoints = record.dataPoints } else { /* Only calculate the datapoints for this record, if we have not calculate it before. */ - for (let j = 0; j < productDefinition.referenceParent.shapes.chartPoints.points.length; j++) { - let point = productDefinition.referenceParent.shapes.chartPoints.points[j] - if (point.pointFormula !== undefined) { - let x = 0 - let y = 0 - eval(point.pointFormula.code) - let dataPoint = { - x: x, - y: y - } + for (let k = 0; k < productDefinition.referenceParent.shapes.chartPoints.length; k++) { + let chartPoints = productDefinition.referenceParent.shapes.chartPoints[k] + for (let j = 0; j < chartPoints.points.length; j++) { + let point = chartPoints.points[j] + if (point.pointFormula !== undefined) { + let x = 0 + let y = 0 + eval(point.pointFormula.code) + let dataPoint = { + x: x, + y: y + } - /* - 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. - */ - dataPoint = timeLineCoordinateSystem.transformThisPoint(dataPoint) + /* + 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. + */ + dataPoint = timeLineCoordinateSystem.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) + /* + 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) - /* We make sure the points do not fall outside the viewport visible area. This step allways need to be done. */ - dataPoint = viewPort.fitIntoVisibleArea(dataPoint) + /* We make sure the points do not fall outside the viewport visible area. This step allways need to be done. */ + dataPoint = viewPort.fitIntoVisibleArea(dataPoint) - /* Store the data point at the local map */ - dataPoints.set(point.id, dataPoint) + /* Store the data point at the local map */ + dataPoints.set(point.id, dataPoint) - if (plotterModuleConfig !== undefined) { - if (plotterModuleConfig.slot !== undefined) { - /* We reset the y coordinate since it will be transformed with another coordinate system to fit into a slot. */ - dataPoint.y = (-1) * y * slotCoordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + if (plotterModuleConfig !== undefined) { + if (plotterModuleConfig.slot !== undefined) { + /* We reset the y coordinate since it will be transformed with another coordinate system to fit into a slot. */ + dataPoint.y = (-1) * y * slotCoordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + } } } }