From 289bcb22aad29e9e299f685263cac67b7e8f6b26 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 17 Dec 2015 15:03:47 +0100 Subject: [PATCH] First attempt cleaning up chart money formatting. --- public/js/accounting.min.js | 4 ++++ public/js/charts.js | 33 ++++++++++++++++++++++-------- resources/twig/layout/default.twig | 2 +- 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 public/js/accounting.min.js diff --git a/public/js/accounting.min.js b/public/js/accounting.min.js new file mode 100644 index 0000000000..8e09b86846 --- /dev/null +++ b/public/js/accounting.min.js @@ -0,0 +1,4 @@ +/*! + * accounting.js v0.4.2, copyright 2014 Open Exchange Rates, MIT license, http://openexchangerates.github.io/accounting.js + */ +(function(p,z){function q(a){return!!(""===a||a&&a.charCodeAt&&a.substr)}function m(a){return u?u(a):"[object Array]"===v.call(a)}function r(a){return"[object Object]"===v.call(a)}function s(a,b){var d,a=a||{},b=b||{};for(d in b)b.hasOwnProperty(d)&&null==a[d]&&(a[d]=b[d]);return a}function j(a,b,d){var c=[],e,h;if(!a)return c;if(w&&a.map===w)return a.map(b,d);for(e=0,h=a.length;ea?"-":"",g=parseInt(y(Math.abs(a||0),h),10)+"",l=3a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal))};c.formatColumn=function(a,b,d,i,e,h){if(!a)return[];var f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format),l=g.pos.indexOf("%s")a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal));if(a.length>k)k=a.length;return a});return j(a,function(a){return q(a)&&a.length", + scaleLabel: " <%= accounting.formatMoney(value) %>", tooltipFillColor: "rgba(0,0,0,0.5)", - multiTooltipTemplate: "<%=datasetLabel%>: <%= '" + currencySymbol + " ' + Number(value).toFixed(2).replace('.', ',') %>" + multiTooltipTemplate: "<%=datasetLabel%>: <%= accounting.formatMoney(value) %>" }; @@ -61,7 +78,7 @@ var defaultPieOptions = { scaleFontSize: 10, responsive: false, tooltipFillColor: "rgba(0,0,0,0.5)", - tooltipTemplate: "<%if (label){%><%=label%>: <%}%>" + currencySymbol + " <%= value %>", + tooltipTemplate: "<%if (label){%><%=label%>: <%}%> <%= accounting.formatMoney(value) %>", }; @@ -90,10 +107,10 @@ var defaultColumnOptions = { scaleFontSize: 10, responsive: false, animation: false, - scaleLabel: "<%= '" + currencySymbol + " ' + Number(value).toFixed(0).replace('.', ',') %>", + scaleLabel: "<%= accounting.formatMoney(value) %>", tooltipFillColor: "rgba(0,0,0,0.5)", - tooltipTemplate: "<%if (label){%><%=label%>: <%}%>" + currencySymbol + " <%= value %>", - multiTooltipTemplate: "<%=datasetLabel%>: " + currencySymbol + " <%= Number(value).toFixed(2).replace('.', ',') %>" + tooltipTemplate: "<%if (label){%><%=label%>: <%}%> <%= accounting.formatMoney(value) %>", + multiTooltipTemplate: "<%=datasetLabel%>: <%= accounting.formatMoney(value) %>" }; var defaultStackedColumnOptions = { @@ -105,9 +122,9 @@ var defaultStackedColumnOptions = { animation: false, scaleFontSize: 10, responsive: false, - scaleLabel: "<%= '" + currencySymbol + " ' + Number(value).toFixed(0).replace('.', ',') %>", + scaleLabel: "<%= accounting.formatMoney(value) %>", tooltipFillColor: "rgba(0,0,0,0.5)", - multiTooltipTemplate: "<%=datasetLabel%>: " + currencySymbol + " <%= Number(value).toFixed(2).replace('.', ',') %>" + multiTooltipTemplate: "<%=datasetLabel%>: <%= accounting.formatMoney(value) %>" }; diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig index 143024d7b6..9542222ad3 100644 --- a/resources/twig/layout/default.twig +++ b/resources/twig/layout/default.twig @@ -157,7 +157,7 @@ - +