From 181562938b81607f57aeff03e98d46d61c012320 Mon Sep 17 00:00:00 2001 From: Greg Lin Date: Sat, 14 Oct 2023 13:09:59 -0500 Subject: [PATCH] Use toLocaleString for more useful examples of formatting currency --- vignettes/cookbook/cookbook.Rmd | 4 ++-- vignettes/examples.Rmd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vignettes/cookbook/cookbook.Rmd b/vignettes/cookbook/cookbook.Rmd index 40ed349c..233f0d68 100644 --- a/vignettes/cookbook/cookbook.Rmd +++ b/vignettes/cookbook/cookbook.Rmd @@ -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' }) }") ) ), @@ -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' }) }") ) ), diff --git a/vignettes/examples.Rmd b/vignettes/examples.Rmd index 654d9f42..54fa1f7a 100644 --- a/vignettes/examples.Rmd +++ b/vignettes/examples.Rmd @@ -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' }) }") ) ) @@ -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' }) }") ) ),