Skip to content

Commit 103b910

Browse files
committed
global rounding to 3 decimal
1 parent 3cb8408 commit 103b910

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

pecan/Frontend/pecan-live-dashboard/src/lib/DataStore.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,24 @@ class DataStore {
8989

9090
const msgID = message.msgID;
9191

92+
// Round sensor readings to 3 decimal places for cleaner display
93+
const roundedData = { ...message.data };
94+
Object.keys(roundedData).forEach((key) => {
95+
const signal = roundedData[key];
96+
if (signal && typeof signal.sensorReading === 'number') {
97+
roundedData[key] = {
98+
...signal,
99+
sensorReading: Math.round(signal.sensorReading * 1000) / 1000,
100+
};
101+
}
102+
});
103+
92104
// Create the sample
93105
const sample: TelemetrySample = {
94106
timestamp,
95107
msgID,
96108
messageName: message.messageName,
97-
data: message.data,
109+
data: roundedData,
98110
rawData: message.rawData,
99111
};
100112

0 commit comments

Comments
 (0)