mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
y axis formatter
This commit is contained in:
parent
bee42187b9
commit
663f26a12b
@ -19,7 +19,8 @@ import {
|
||||
getDisplayFormat,
|
||||
getSeriesLabel,
|
||||
getTimeUnit,
|
||||
} from './impact-metrics-utils.ts';
|
||||
formatLargeNumbers,
|
||||
} from './utils.ts';
|
||||
import { fromUnixTime } from 'date-fns';
|
||||
import { useSeriesColor } from './hooks/useSeriesColor.ts';
|
||||
|
||||
@ -254,6 +255,14 @@ export const ImpactMetrics: FC = () => {
|
||||
},
|
||||
ticks: {
|
||||
precision: 0,
|
||||
callback: (
|
||||
value: unknown,
|
||||
): string | number =>
|
||||
typeof value === 'number'
|
||||
? formatLargeNumbers(
|
||||
value,
|
||||
)
|
||||
: (value as number),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -48,3 +48,13 @@ export const getSeriesLabel = (metric: Record<string, string>): string => {
|
||||
|
||||
return `${__name__} (${labelParts})`;
|
||||
};
|
||||
|
||||
export const formatLargeNumbers = (value: number): string => {
|
||||
if (value >= 1000000) {
|
||||
return `${(value / 1000000).toFixed(0)}M`;
|
||||
}
|
||||
if (value >= 1000) {
|
||||
return `${(value / 1000).toFixed(0)}k`;
|
||||
}
|
||||
return value.toString();
|
||||
};
|
Loading…
Reference in New Issue
Block a user