Format currency in users locale

This commit is contained in:
Matt Bannon
2023-11-16 17:03:29 +11:00
parent 0cd6f64978
commit 7529daab3e
7 changed files with 42 additions and 46 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
function loadGraph(container, dataPoints, symbol, run) {
function loadGraph(container, dataPoints, currency, run) {
if (run) {
var ctx = document.getElementById(container).getContext('2d');
@@ -8,7 +8,7 @@ function loadGraph(container, dataPoints, symbol, run) {
datasets: [{
data: dataPoints.map(point => point.y),
}],
labels: dataPoints.map(point => `${point.label} (${point.y}${symbol})`),
labels: dataPoints.map(point => `(${new Intl.NumberFormat(navigator.language, { style: 'currency', currency }).format(point.y)})`),
},
options: {
animation: {