Skip to content

Commit 2dc91df

Browse files
authored
Merge pull request #349 from circuitpython/plotter
Fix plotter to handle tuples with ending commas
2 parents 1f534db + 6fccaa1 commit 2dc91df

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

js/common/plotter.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ export function plotValues(chartObj, serialMessage, bufferSize) {
4848

4949
// handle possible tuple in textLine
5050
if (textLine.startsWith("(") && textLine.endsWith(")")) {
51-
textLine = "[" + textLine.substring(1, textLine.length - 1) + "]";
51+
textValues = textLine.substring(1, textLine.length - 1).trim();
52+
// Python tuples can end with a comma, but JS arrays cannot
53+
if (textValues.endsWith(",")) {
54+
textValues = textValues.substring(0, textValues.length - 1);
55+
}
56+
textLine = "[" + textValues + "]";
5257
console.log("after tuple conversion: " + textLine);
5358
}
5459

0 commit comments

Comments
 (0)