Skip to content

Commit 878034b

Browse files
committed
warn once encountered a bad format
1 parent 1efc41e commit 878034b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/lib/index.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,29 @@ lib.adjustFormat = function adjustFormat(formatStr) {
2929
return formatStr;
3030
};
3131

32-
lib.noFormat = function(value) { return String(value); };
32+
var seenBadFormats = {};
33+
lib.warnBadFormat = function(f) {
34+
var key = String(f);
35+
if(!seenBadFormats[key]) {
36+
seenBadFormats[key] = 1;
37+
lib.warn('encountered bad format: "' + key + '"');
38+
}
39+
};
40+
41+
lib.noFormat = function(value) {
42+
return String(value);
43+
};
3344

3445
lib.numberFormat = function(formatStr) {
46+
var fn;
3547
try {
36-
formatStr = d3Format(lib.adjustFormat(formatStr));
48+
fn = d3Format(lib.adjustFormat(formatStr));
3749
} catch(e) {
50+
lib.warnBadFormat(formatStr);
3851
return lib.noFormat;
3952
}
4053

41-
return formatStr;
54+
return fn;
4255
};
4356

4457
lib.nestedProperty = require('./nested_property');

src/plots/plots.js

+1
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ function getFormatter(formatObj, separators) {
709709
Lib.adjustFormat(formatStr)
710710
);
711711
} catch(e) {
712+
Lib.warnBadFormat(formatStr);
712713
return Lib.noFormat;
713714
}
714715

0 commit comments

Comments
 (0)