Conformance: Have activity Log Results chart, Effect done.

This commit is contained in:
chiayin
2023-07-20 15:45:22 +08:00
parent 97ac9535f9
commit dc4ede1d62
7 changed files with 496 additions and 182 deletions

View File

@@ -0,0 +1,14 @@
/**
* 將數字轉換成簡寫的形式1k、1m、1b等
* @param {number} number
* @returns {string}
*/
export default function abbreviateNumber(number) {
const SI_SYMBOLS = ["", "k", "m", "b", "t"];
const tier = Math.log10(Math.abs(number)) / 3 | 0;
const suffix = SI_SYMBOLS[tier];
const scale = Math.pow(10, tier * 3);
const scaledNumber = number / scale;
return Math.round(scaledNumber) + suffix;
}