Skip to content

Commit

Permalink
fix: show fraction digits only for non-whole number percentages
Browse files Browse the repository at this point in the history
See: 4e053b0
  • Loading branch information
marcel-bitfly committed Dec 13, 2024
1 parent 4e053b0 commit 903b3a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/components/bc/format/BcFormatPercent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ const data = computed(() => {
const localPercent = percent ?? calculatePercent(value, base)
label = new Intl.NumberFormat('en', {
maximumFractionDigits,
minimumFractionDigits,
// due to the default value of minimumFractionDigits: 2
// there will be an error when `minimumFractionDigits > maximumFractionDitigs`
minimumFractionDigits: minimumFractionDigits > maximumFractionDigits
? maximumFractionDigits
: minimumFractionDigits,
style: 'unit',
trailingZeroDisplay,
unit: 'percent',
Expand Down

0 comments on commit 903b3a8

Please sign in to comment.