diff --git a/Plotting/Plotter.js b/Plotting/Plotter.js index 844ace277..85f3e6873 100644 --- a/Plotting/Plotter.js +++ b/Plotting/Plotter.js @@ -551,16 +551,16 @@ function newPlotter () { let atMousePosition = false if (userPositionDate >= record.begin && userPositionDate <= record.end) { - if (record.rate === undefined) { - /* Current Record depends only on begin and end. */ - atMousePosition = true - thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) - } else { + if (record.rate !== undefined && productDefinition.referenceParent.config.useRateAtMousePosition === true) { /* Current Record depends also on rate */ if (record.rate >= minUserPositionRate && record.rate <= maxUserPositionRate) { atMousePosition = true thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) } + } else { + /* Current Record depends only on begin and end. */ + atMousePosition = true + thisObject.container.eventHandler.raiseEvent('Current Record Changed', record) } } diff --git a/Plotting/RecordValues.js b/Plotting/RecordValues.js index 2e66ad2da..8f84ba629 100644 --- a/Plotting/RecordValues.js +++ b/Plotting/RecordValues.js @@ -12,7 +12,6 @@ function newRecordValues () { let tradingSystem let tradingEngine let productDefinition - let productTargetNode let propertyTargetNodeMap = new Map() return thisObject @@ -20,7 +19,6 @@ function newRecordValues () { tradingSystem = undefined tradingEngine = undefined productDefinition = undefined - productTargetNode = undefined propertyTargetNodeMap = undefined } @@ -28,15 +26,45 @@ function newRecordValues () { tradingSystem = canvas.designSpace.workspace.getHierarchyHeadsById(pTradingSystem.id) tradingEngine = canvas.designSpace.workspace.getHierarchyHeadsById(pTradingEngine.id) productDefinition = pProductDefinition - productTargetNode = eval(productDefinition.config.nodePath) - for (let i = 0; i < productDefinition.record.properties.length; i++) { - let property = productDefinition.record.properties[i] - if (property.config.nodePath !== undefined) { - let propertyRoot = eval(property.config.nodePath) - propertyTargetNodeMap.set(property.id, propertyRoot) - } else { - propertyTargetNodeMap.set(property.id, productTargetNode) + /* + The product root can be a node or a node property of type array. + */ + let productRoot = eval(productDefinition.config.nodePath) + + if (productDefinition.config.nodePathType === 'array') { + /* + This means that the configured nodePath is not pointing to a node, but to a node property that is an array. + For that reason we will assume that each element of the array is a record to be outputed + */ + for (let index = 0; index < productRoot.length; index++) { + /* + The Product Root Node is the root of the node hiriarchy from where we are going to extract the record values. + */ + let productRootNode = productRoot[index] + scanProperties(productRootNode, index) + } + } else { + /* + This means that the configured nodePath points to a single node, which is the one whose children constitutes + the record to be saved at the output file. + */ + /* + The Product Root Node is the root of the node hiriarchy from where we are going to extract the record values. + */ + let productRootNode = productRoot + scanProperties(productRootNode) + } + + function scanProperties (productRootNode, index) { + for (let i = 0; i < productDefinition.record.properties.length; i++) { + let property = productDefinition.record.properties[i] + if (property.config.nodePath !== undefined) { + let propertyRoot = eval(property.config.nodePath) + propertyTargetNodeMap.set(property.id, propertyRoot) + } else { + propertyTargetNodeMap.set(property.id, productRootNode) + } } } }