From 7f0033b4e391641b48b1dc83bd4c5a1b9319ad95 Mon Sep 17 00:00:00 2001 From: Rebecca Williams Date: Wed, 10 Apr 2024 17:55:37 +0100 Subject: [PATCH 1/2] Use the precision metadata to format each element in a waveform PV --- src/main/webapp/widgets/textupdate.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/widgets/textupdate.js b/src/main/webapp/widgets/textupdate.js index 3a972e9..ad7dd73 100644 --- a/src/main/webapp/widgets/textupdate.js +++ b/src/main/webapp/widgets/textupdate.js @@ -50,7 +50,7 @@ function format_pv_data_as_text(widget, data) // Otherwise use precision from data if (precision === undefined && data.precision !== undefined) precision = data.precision; - + let text; if (data.text !== undefined) { @@ -89,7 +89,18 @@ function format_pv_data_as_text(widget, data) if (data.precision === undefined) text = data.value.toString(); else - if (typeof data.value.toFixed == 'function') + if (Array.isArray(data.value)) { + text = ""; + for (let i = 0; i < data.value.length; i++){ + if (typeof data.value[i].toFixed == 'function') + text = text.concat(data.value[i].toFixed(precision)); + else + text = text.concat(data.value[i].toString()); + if (i < data.value.length - 1) + text = text.concat(", "); + } + } + else if (typeof data.value.toFixed == 'function') text = data.value.toFixed(precision); else text = data.value.toString(); From 26446e9d0d8706e4d020ab65f72d6a751d023366 Mon Sep 17 00:00:00 2001 From: Rebecca Williams Date: Thu, 9 May 2024 16:22:03 +0100 Subject: [PATCH 2/2] Maintain previous formatting --- src/main/webapp/widgets/textupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/widgets/textupdate.js b/src/main/webapp/widgets/textupdate.js index ad7dd73..ca990f9 100644 --- a/src/main/webapp/widgets/textupdate.js +++ b/src/main/webapp/widgets/textupdate.js @@ -50,7 +50,7 @@ function format_pv_data_as_text(widget, data) // Otherwise use precision from data if (precision === undefined && data.precision !== undefined) precision = data.precision; - + let text; if (data.text !== undefined) {