Numeric Display Format
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:
| Property | Type | Description |
|---|---|---|
| Abs | boolean | Returns absolute value of cell value |
| Ceiling | boolean | Returns smallest integer greater than cell value |
| Content | string | number | Replaces cell value with supplied value (that can contain Template Literals) |
| Empty | boolean | Show nothing in cell (but underlying value remains) |
| Floor | boolean | Returns largest integer cell value |
| FractionDigits | number | Number of digits to show in Fractions (up to 20) |
| FractionSeparator | string | Separator to use in fractions |
| IntegerDigits | number | Number of digits to show for Integers (up to 20) |
| IntegerSeparator | string | Separator to use in Integers |
| Multiplier | number | Multiplier to use on cell value |
| Notation | 'standard' | 'scientific' | Numeric notation to use when rendering the value. |
| Parentheses | boolean | Shows negative numbers in parentheses |
| Prefix | string | Prefix to use before cell value |
| Round | boolean | Rounds cell value |
| Suffix | string | Suffix to use after cell value |
| Truncate | boolean | Truncates cell value |
| ZeroDisplay | string | When 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. -, —) |
- In this example 2 Format Columns use a full
NumberFormatterobject (not presets):Github Stars—Multiplier0.001and suffixK(one decimal place)Issue Change— negative values in parentheses viaParentheses: 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
NumberFormatterobject 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) | Category | Raw Value | Display Format |
|---|---|---|---|
| Dollar | Currency | 123.4567 | $123.46 |
| Sterling | Currency | 123.4567 | £123.46 |
| Euro | Currency | 123.4567 | €123.46 |
| Yen | Currency | 1234 | ¥1,234 |
| Bitcoin | Currency | 0.12345678 | ₿0.12345678 |
K (Thousand) | Magnitude | 123456 | 123.456K |
M (Million) | Magnitude | 123456789 | 123.456789M |
B (Billion) | Magnitude | 1234567890 | 1.23456789B |
| Integer | General | 1234.56 | 1,235 |
| Decimal | General | 1234.5678 | 1,234.57 |
| Percentage | General | 0.54321 | 54.32% |
| Scientific | General | 1234567 | 1.23E6 |
| Accounting | Specialised | -1234.56 | (1,234.56) |
FX Rate (FXRate) | Specialised | 1.23456 | 1.2346 |
bps (BasisPoints) | Specialised | 0.0125 | 125 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
10000and appendsbps - Scientific uses JavaScript's
Intl.NumberFormatwithnotation: 'scientific', capped to 2 fraction digits
- In this example, 3 Format Columns have
DisplayFormatset 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 aKsuffix)
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.54 → 54%), 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.