Skip to content

Commit fbe522a

Browse files
committed
fix: show integers for values below 1k in trends chart tooltip
1 parent 75bce20 commit fbe522a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/components/Package/TrendsChart.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ function setIsZoom({ isZoom }: { isZoom: boolean }) {
7474
const { width } = useElementSize(rootEl)
7575
7676
const compactNumberFormatter = useCompactNumberFormatter()
77+
const integerFormatter = useNumberFormatter({
78+
maximumFractionDigits: 0,
79+
})
7780
7881
onMounted(async () => {
7982
rootEl.value = document.documentElement
@@ -1541,7 +1544,10 @@ const chartConfig = computed<VueUiXyConfig>(() => {
15411544
.map((d: Record<string, any>) => {
15421545
const label = String(d?.name ?? '').trim()
15431546
const raw = Number(d?.value ?? 0)
1544-
const v = compactNumberFormatter.value.format(Number.isFinite(raw) ? raw : 0)
1547+
const v =
1548+
raw > 1_000
1549+
? compactNumberFormatter.value.format(Number.isFinite(raw) ? raw : 0)
1550+
: integerFormatter.value.format(Number.isFinite(raw) ? raw : 0)
15451551
15461552
if (!hasMultipleItems) {
15471553
// We don't need the name of the package in this case, since it is shown in the xAxis label

0 commit comments

Comments
 (0)