mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 16:45:35 +01:00
v1 revenue report for clickhouse
This commit is contained in:
parent
e173f375c7
commit
2707b39473
19 changed files with 427 additions and 243 deletions
|
|
@ -47,6 +47,9 @@ export function formatNumber(n: string | number) {
|
|||
export function formatLongNumber(value: number) {
|
||||
const n = Number(value);
|
||||
|
||||
if (n >= 1000000000) {
|
||||
return `${(n / 1000000).toFixed(1)}b`;
|
||||
}
|
||||
if (n >= 1000000) {
|
||||
return `${(n / 1000000).toFixed(1)}m`;
|
||||
}
|
||||
|
|
@ -78,3 +81,26 @@ export function stringToColor(str: string) {
|
|||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
export function formatCurrency(value: number, currency: string, locale = 'en-US') {
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
export function formatLongCurrency(value: number, currency: string, locale = 'en-US') {
|
||||
const n = Number(value);
|
||||
|
||||
if (n >= 1000000000) {
|
||||
return `${formatCurrency(n / 1000000000, currency, locale)}b`;
|
||||
}
|
||||
if (n >= 1000000) {
|
||||
return `${formatCurrency(n / 1000000, currency, locale)}m`;
|
||||
}
|
||||
if (n >= 1000) {
|
||||
return `${formatCurrency(n / 1000, currency, locale)}k`;
|
||||
}
|
||||
|
||||
return formatCurrency(n / 1000, currency, locale);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue