wallos/scripts/stats.js
Miguel Ribeiro 6200fa5e87
feat: new statistics per payment method (#124)
* feat: new statistics per payment method

* fix: fix typo on english language file

* fix: use translation text for deleting subscriptions
2024-02-18 16:26:54 +01:00

28 lines
980 B
JavaScript

function loadGraph(container, dataPoints, currency, run) {
if (run) {
var ctx = document.getElementById(container).getContext('2d');
var chart = new Chart(ctx, {
type: 'pie',
data: {
datasets: [{
data: dataPoints.map(point => point.y),
}],
labels: dataPoints.map(point => {
if (currency) {
return `${point.label} (${new Intl.NumberFormat(navigator.language, { style: 'currency', currency }).format(point.y)})`;
} else {
return `${point.label} (${new Intl.NumberFormat(navigator.language).format(point.y)})`;
}
}),
},
options: {
animation: {
animateRotate: true,
animateScale: true,
},
},
});
}
}