Skip to content

Commit

Permalink
Merge pull request #31 from rjwills28/format_precision_for_waveforms
Browse files Browse the repository at this point in the history
Use the precision field to format waveform data
  • Loading branch information
kasemir authored May 10, 2024
2 parents 69ab507 + 26446e9 commit 178b9b8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/webapp/widgets/textupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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();
Expand Down

0 comments on commit 178b9b8

Please sign in to comment.