Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmyomahony/82af445f5df46cb981a7774f6a87b3e2 to your computer and use it in GitHub Desktop.
Save timmyomahony/82af445f5df46cb981a7774f6a87b3e2 to your computer and use it in GitHub Desktop.
var UK = d3.locale({
"decimal": ".",
"thousands": ",",
"grouping": [3],
"currency": ["£", ""],
"dateTime": "%a %b %e %X %Y",
"date": "%m/%d/%Y",
"time": "%H:%M:%S",
"periods": ["AM", "PM"],
"days": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
"shortDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
"months": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
"shortMonths": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
});
...
// Getting M, B thousands etc.
// https://github.com/d3/d3/issues/2241
var formatSi = UK.numberFormat("$.2s");
function formatAbbreviation(x) {
var s = formatSi(x);
switch (s[s.length - 1]) {
case "G": return s.slice(0, -1) + "B";
}
return s;
}
var chartTotalSpend = dc.numberDisplay("#total-transfer-spend");
chartTotalSpend
.formatNumber(formatAbbreviation)
.valueAccessor(function (d) {
return d;
})
.group(totalFeesSeasonal);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment