From 418c574b289ea5721f009a1df823500818227181 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 13 Dec 2019 10:45:37 +0100 Subject: [PATCH] Panels without coding --- Panels/PlotterPanel.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index e014bc4f1..1a54b7299 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -94,11 +94,33 @@ function newPlotterPanel () { try { eval(panelNode.javascriptCode.code) } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> javascriptCode.code = ' + panelNode.javascriptCode.code) } } } - /* Second we go through the panel labels. */ + /* Second we go through the panel data. */ + for (let i = 0; i < panelNode.panelData.length; i++) { + let panelData = panelNode.panelData[i] + + let value = 'No value defined' + + if (panelData.dataFormula !== undefined) { + try { + value = eval(panelData.dataFormula.code) + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> dataFormula.code = ' + panelNode.dataFormula.code) } + } + } + + if (panelData.code.valueDecimals !== undefined) { + value = value.toFixed(panelData.code.valueDecimals) + } + + printLabel(panelData.code.labelText, X_AXIS, PANEL_HEIGHT * panelData.code.labelPosition / 100, '1') + printLabel(value, X_AXIS, PANEL_HEIGHT * panelData.code.valuePosition / 100, '0.50') + } function printLabel (labelToPrint, x, y, opacity) { let labelPoint @@ -126,4 +148,3 @@ function newPlotterPanel () { browserCanvasContext.fill() } } -