Skip to content

Commit

Permalink
Allow SI prefixes to be set in locale.
Browse files Browse the repository at this point in the history
This could serve as an escape hatch for somebody who wanted to support custom SI prefixes. This could be used to solve d3#33 (binary prefixes) or it could be used to support something custom like American english numbers (1,000,000,000 => 1B [billion] instead of 1G [giga]).
  • Loading branch information
nicksrandall authored Feb 28, 2017
1 parent b7e1c02 commit b71f7cd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import formatSpecifier from "./formatSpecifier";
import formatTypes from "./formatTypes";
import {prefixExponent} from "./formatPrefixAuto";

var prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
var defaultPrefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];

function identity(x) {
return x;
Expand All @@ -13,7 +13,8 @@ function identity(x) {
export default function(locale) {
var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity,
currency = locale.currency,
decimal = locale.decimal;
decimal = locale.decimal,
prefixes = locale.prefixes || defaultPrefixes;

function newFormat(specifier) {
specifier = formatSpecifier(specifier);
Expand Down

0 comments on commit b71f7cd

Please sign in to comment.