-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #831 from invariant-labs/fix-stats-chart-issues
Fix chart issues
- Loading branch information
Showing
4 changed files
with
49 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { trimZeros } from './utils' | ||
|
||
export const formatLargeNumber = (number: number) => { | ||
const suffixes = ['', 'K', 'M', 'B', 'T', 'Q'] | ||
|
||
if (number < 1000) { | ||
return number.toFixed(1) | ||
} | ||
|
||
const suffixIndex = Math.floor(Math.log10(number) / 3) | ||
const scaledNumber = number / Math.pow(1000, suffixIndex) | ||
|
||
return `${trimZeros(scaledNumber.toFixed(1))}${suffixes[suffixIndex]}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const trimZeros = (amount: string) => { | ||
try { | ||
return parseFloat(amount).toString() | ||
} catch (error) { | ||
return amount | ||
} | ||
} |