Skip to content

Commit 891aced

Browse files
committed
Fix merge error with localized decimal.
Also, don't use grouping when locale reports grouping "0".
1 parent fd2b134 commit 891aced

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

d3.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,6 +3467,7 @@
34673467
if (!zfill && comma) value = d3_format_group(value);
34683468
var length = basePrefix.length + value.length + (zcomma ? 0 : negative.length), padding = length < width ? (new Array(length = width - length + 1)).join(fill) : "";
34693469
if (zcomma) value = d3_format_group(padding + value);
3470+
if (d3_format_decimalPoint) value.replace(".", d3_format_decimalPoint);
34703471
negative += basePrefix;
34713472
return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + suffix;
34723473
};

d3.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/format.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,19 @@ d3.format = function(specifier) {
6363
// Convert to the desired precision.
6464
value = type(value, precision);
6565

66+
// If the fill character is not "0", grouping is applied before padding.
6667
if (!zfill && comma) value = d3_format_group(value);
68+
6769
var length = basePrefix.length + value.length + (zcomma ? 0 : negative.length),
6870
padding = length < width ? new Array(length = width - length + 1).join(fill) : "";
71+
72+
// If the fill character is "0", grouping is applied after padding.
6973
if (zcomma) value = d3_format_group(padding + value);
74+
75+
if (d3_format_decimalPoint) value.replace(".", d3_format_decimalPoint);
76+
7077
negative += basePrefix;
78+
7179
return (align === "<" ? negative + value + padding
7280
: align === ">" ? padding + negative + value
7381
: align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length)

src/locale.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function write() {
2424
puts(fs.readFileSync(process.argv[2], "utf8").replace(/\{([^\}]+)\}/g, function(d, k) {
2525
d = formats[k];
2626
return k === "grouping"
27-
? d === "\"127\"" ? null : d.replace(/^"/, "[").replace(/"$/, "]").replace(/;/, ", ")
27+
? d === "\"127\"" || d === "\"0\"" ? null : d.replace(/^"/, "[").replace(/"$/, "]").replace(/;/, ", ")
2828
: d == null ? null : d;
2929
}));
3030
}

0 commit comments

Comments
 (0)