Skip to content

Commit

Permalink
Use toLocaleString for more useful examples of formatting currency
Browse files Browse the repository at this point in the history
  • Loading branch information
glin committed Oct 14, 2023
1 parent bcb0884 commit 1815629
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions vignettes/cookbook/cookbook.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ reactable(
state.sortedData.forEach(function(row) {
total += row[column.id]
})
return '$' + total.toFixed(2)
return total.toLocaleString('en-US', { style: 'currency', currency: 'USD' })
}")
)
),
Expand All @@ -601,7 +601,7 @@ reactable(
state.sortedData.forEach(function(row) {
total += row[column.id]
})
return '$' + total.toFixed(2)
return total.toLocaleString('en-US', { style: 'currency', currency: 'USD' })
}")
)
),
Expand Down
4 changes: 2 additions & 2 deletions vignettes/examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ reactable(
aggregate = "sum",
# Render aggregated cell as currency
aggregated = JS("function(cellInfo) {
return '$' + cellInfo.value.toFixed(2)
return cellInfo.value.toLocaleString('en-US', { style: 'currency', currency: 'USD' })
}")
)
)
Expand Down Expand Up @@ -918,7 +918,7 @@ reactable(
state.sortedData.forEach(function(row) {
total += row[column.id]
})
return '$' + total.toFixed(2)
return total.toLocaleString('en-US', { style: 'currency', currency: 'USD' })
}")
)
),
Expand Down

0 comments on commit 1815629

Please sign in to comment.