mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 09:33:19 +03:00
Fix money values on graphs and conversions
graph tooltips (#4717)
* Fix conversions graph tooltips * Show revenue value instead of `undefined` in graph This broke due to the unification of formatters. Not sure if this is the best fix
This commit is contained in:
parent
d727ba5ed5
commit
d648505a9b
@ -14,6 +14,7 @@ export type FormattableMetric =
|
||||
| 'total_visitors'
|
||||
| 'current_visitors'
|
||||
| 'exit_rate'
|
||||
| 'conversions'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type ValueType = any
|
||||
@ -30,6 +31,8 @@ export const MetricFormatterShort: Record<
|
||||
visitors: numberShortFormatter,
|
||||
visits: numberShortFormatter,
|
||||
|
||||
conversions: numberShortFormatter,
|
||||
|
||||
time_on_page: durationFormatter,
|
||||
visit_duration: durationFormatter,
|
||||
|
||||
@ -55,6 +58,8 @@ export const MetricFormatterLong: Record<
|
||||
visitors: numberLongFormatter,
|
||||
visits: numberLongFormatter,
|
||||
|
||||
conversions: numberLongFormatter,
|
||||
|
||||
time_on_page: durationFormatter,
|
||||
visit_duration: durationFormatter,
|
||||
|
||||
|
@ -1,15 +1,21 @@
|
||||
import { numberLongFormatter, numberShortFormatter } from "./number-formatter"
|
||||
|
||||
type Money = { long: string, short: string }
|
||||
|
||||
export function formatMoneyShort(value: Money | null) {
|
||||
if (value) {
|
||||
export function formatMoneyShort(value: Money | number | null) {
|
||||
if (typeof value == 'number') {
|
||||
return numberShortFormatter(value)
|
||||
} else if (value) {
|
||||
return value.short
|
||||
} else {
|
||||
return "-"
|
||||
}
|
||||
}
|
||||
|
||||
export function formatMoneyLong(value: Money | null) {
|
||||
if (value) {
|
||||
export function formatMoneyLong(value: Money | number | null) {
|
||||
if (typeof value == 'number') {
|
||||
return numberLongFormatter(value)
|
||||
} else if (value) {
|
||||
return value.long
|
||||
} else {
|
||||
return "-"
|
||||
|
Loading…
Reference in New Issue
Block a user