Summary

  • AdapTable provides a number of Display Formats to be used with Numeric Columns

AdapTable ships with a number of System Number Display Formats.

These are designed to provide Display Formats for numeric columns.

They are contained in the Number Formatter object defined as follows:

PropertyTypeDescription
AbsbooleanReturns absolute value of cell value
CeilingbooleanReturns smallest integer greater than cell value
Contentstring | numberReplaces cell value with supplied value (that can contain Template Literals)
EmptybooleanShow nothing in cell (but underlying value remains)
FloorbooleanReturns largest integer cell value
FractionDigitsnumberNumber of digits to show in Fractions (up to 20)
FractionSeparatorstringSeparator to use in fractions
IntegerDigitsnumberNumber of digits to show for Integers (up to 20)
IntegerSeparatorstringSeparator to use in Integers
MultipliernumberMultiplier to use on cell value
Notation'standard' | 'scientific'Numeric notation to use when rendering the value.
ParenthesesbooleanShows negative numbers in parentheses
PrefixstringPrefix to use before cell value
RoundbooleanRounds cell value
SuffixstringSuffix to use after cell value
TruncatebooleanTruncates cell value
ZeroDisplaystringWhen the numeric value is zero (after multiplier and rounding): - omitted / undefined, or '0' — use normal formatting (e.g. 0, 0.00) - '' — show a blank cell (user cleared the default 0 in the wizard) - any other string — show that text (e.g. -, )
Column Formatting: Numeric Display Formats
Fork
  • In this example 2 Format Columns use a full NumberFormatter object (not presets):
    • Github StarsMultiplier 0.001 and suffix K (one decimal place)
    • Issue Change — negative values in parentheses via Parentheses: true (no fraction digits)

Numeric Presets

AdapTable provides 15 preset numeric Display Formats as a convenience feature.

These presets cover the most common use cases, and general-purpose number formats, out of the box, e.g. currency, magnitude, rate etc

Each preset is a short-hand name (e.g. 'Dollar', 'Percentage') containing a set of numeric format options.

Note

  • This allows you to specify the preset (e.g. Dollar) without supplying the details (e.g. FractionDigits, Prefix, etc.)
  • AdapTable will convert the preset into a fully formed Display Format at runtime on your behalf

You can use a preset directly in Format Column Initial State, by simply assigning its name to DisplayFormat:

DisplayFormat: 'Dollar';

Hint

  • You can later fall back to the long-form NumberFormatter object if you need to tweak any of the underlying options
  • e.g. add a custom suffix, fraction digits, multiplier, etc.

UI Wizard

The presets are also available in the Format Column UI Wizard.

This allows run-time users to create display formats quickly.

The wizard arranges the Presets into 4 groups: Currencies, Magnitude, General Numeric and Specialised.

The Presets provided by AdapTable are:

Name (and UI Label)CategoryRaw ValueDisplay Format
DollarCurrency123.4567$123.46
SterlingCurrency123.4567£123.46
EuroCurrency123.4567€123.46
YenCurrency1234¥1,234
BitcoinCurrency0.12345678₿0.12345678
K (Thousand)Magnitude123456123.456K
M (Million)Magnitude123456789123.456789M
B (Billion)Magnitude12345678901.23456789B
IntegerGeneral1234.561,235
DecimalGeneral1234.56781,234.57
PercentageGeneral0.5432154.32%
ScientificGeneral12345671.23E6
AccountingSpecialised-1234.56(1,234.56)
FX Rate (FXRate)Specialised1.234561.2346
bps (BasisPoints)Specialised0.0125125 bps

Note

  • Accounting prints negative numbers in parentheses (positives render plain) — a long-standing finance convention
  • Basis Points assumes the raw value is a decimal rate (1 = 100%), multiplies by 10000 and appends bps
  • Scientific uses JavaScript's Intl.NumberFormat with notation: 'scientific', capped to 2 fraction digits
Column Formatting: Numeric Display Format Presets
Fork
  • In this example, 3 Format Columns have DisplayFormat set to a preset name directly (AdapTable resolves these at runtime):
    • Open/Total Issues'Percentage' (calculated ratio column)
    • Issue Change'Accounting' (negatives in parentheses)
    • Github Stars'Thousand' (values shown in thousands with a K suffix)

FAQ

Can we show a currency symbol? Yes. Use a preset such as 'Dollar', 'Sterling', or 'Euro', or set Prefix / Suffix on a NumberFormatter.

Can negative numbers appear in parentheses? Yes. Use the 'Accounting' preset, or set Parentheses: true on a NumberFormatter.

Can we show percentages? Yes. Use the 'Percentage' preset (expects a decimal rate, e.g. 0.5454%), or set Multiplier: 100 and Suffix: '%' yourself.

Can we show large numbers as K / M / B? Yes. Use 'Thousand', 'Million', or 'Billion', or set Multiplier and Suffix manually (see the options demo above).

If we show no fraction digits, does AdapTable round? Yes. For example, 11.87 with FractionDigits: 0 displays as 12.

When is a preset not enough? Use a full NumberFormatter when you need a mix the presets do not provide — for example Prefix: '≈ ', Multiplier: 0.01, Suffix: ' pts', and FractionDigits: 1 on the same column.