Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(editor): too many digits after decimal point in table calculations (#9471)

Olegade764b18844
diff --git a/blocksuite/affine/data-view/src/core/statistics/number.ts b/blocksuite/affine/data-view/src/core/statistics/number.ts
index e19af57275..4f07245c14 100644
--- a/blocksuite/affine/data-view/src/core/statistics/number.ts
+++ b/blocksuite/affine/data-view/src/core/statistics/number.ts
@@ -30,7 +30,9 @@ export const numberStatsFunctions: StatisticsConfig[] = [
if (numbers.length === 0) {
return 'None';
}
- return (numbers.reduce((a, b) => a + b, 0) / numbers.length).toString();
+ return parseFloat(
+ (numbers.reduce((a, b) => a + b, 0) / numbers.length).toFixed(2)
+ ).toString();
},
}),
createStatisticConfig({
@@ -49,7 +51,7 @@ export const numberStatsFunctions: StatisticsConfig[] = [
const a = arr[index];
const b = arr[index - 1];
if (a == null || b == null) return 'None';
- result = (a + b) / 2;
+ result = parseFloat(((a + b) / 2).toFixed(2));
}
return result?.toString() ?? 'None';
},
@@ -120,7 +122,7 @@ export const numberStatsFunctions: StatisticsConfig[] = [
if (min == null || max == null) {
return 'None';
}
- return (max - min).toString();
+ return parseFloat((max - min).toFixed(2)).toString();
},
}),
];