File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -29,16 +29,29 @@ lib.adjustFormat = function adjustFormat(formatStr) {
29
29
return formatStr ;
30
30
} ;
31
31
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
+ } ;
33
44
34
45
lib . numberFormat = function ( formatStr ) {
46
+ var fn ;
35
47
try {
36
- formatStr = d3Format ( lib . adjustFormat ( formatStr ) ) ;
48
+ fn = d3Format ( lib . adjustFormat ( formatStr ) ) ;
37
49
} catch ( e ) {
50
+ lib . warnBadFormat ( formatStr ) ;
38
51
return lib . noFormat ;
39
52
}
40
53
41
- return formatStr ;
54
+ return fn ;
42
55
} ;
43
56
44
57
lib . nestedProperty = require ( './nested_property' ) ;
Original file line number Diff line number Diff line change @@ -709,6 +709,7 @@ function getFormatter(formatObj, separators) {
709
709
Lib . adjustFormat ( formatStr )
710
710
) ;
711
711
} catch ( e ) {
712
+ Lib . warnBadFormat ( formatStr ) ;
712
713
return Lib . noFormat ;
713
714
}
714
715
You can’t perform that action at this time.
0 commit comments