Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add thousands format for numbers #2261

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading