Skip to content

Commit

Permalink
feat: add thousands format for numbers (#2261)
Browse files Browse the repository at this point in the history
- Closes #2253
  • Loading branch information
wusteven815 authored Oct 22, 2024
1 parent 6b949d5 commit 0802f8a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class DecimalFormatContextMenu {
format: DecimalColumnFormatter.FORMAT_BASIS_POINTS,
group: DecimalFormatContextMenu.presetGroup,
},
{
format: DecimalColumnFormatter.FORMAT_THOUSANDS,
group: DecimalFormatContextMenu.presetGroup,
},
{
format: DecimalColumnFormatter.FORMAT_MILLIONS,
group: DecimalFormatContextMenu.presetGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class IntegerFormatContextMenu {
onCustomFormatChange: (value: IntegerColumnFormat | null) => void
): FormatContextMenuOption[] {
const formatItems = [
{
format: IntegerColumnFormatter.FORMAT_THOUSANDS,
group: IntegerFormatContextMenu.presetGroup,
},
{
format: IntegerColumnFormatter.FORMAT_MILLIONS,
group: IntegerFormatContextMenu.presetGroup,
Expand Down
6 changes: 6 additions & 0 deletions packages/jsapi-utils/src/formatters/DecimalColumnFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export class DecimalColumnFormatter extends TableColumnFormatter<number> {
10000
);

static FORMAT_THOUSANDS = DecimalColumnFormatter.makePresetFormat(
'Thousands',
'##0.000 k',
0.001
);

static FORMAT_MILLIONS = DecimalColumnFormatter.makePresetFormat(
'Millions',
'###,##0.000 mm',
Expand Down
6 changes: 6 additions & 0 deletions packages/jsapi-utils/src/formatters/IntegerColumnFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ export class IntegerColumnFormatter extends TableColumnFormatter<number> {

static DEFAULT_FORMAT_STRING = '###,##0';

static FORMAT_THOUSANDS = IntegerColumnFormatter.makePresetFormat(
'Thousands',
'##0.000 k',
0.001
);

static FORMAT_MILLIONS = IntegerColumnFormatter.makePresetFormat(
'Millions',
'###,##0.000 mm',
Expand Down

0 comments on commit 0802f8a

Please sign in to comment.