@@ -22,6 +22,7 @@ nv.models.axis = function() {
22
22
, fontSize = undefined
23
23
, duration = 250
24
24
, dispatch = d3 . dispatch ( 'renderEnd' )
25
+ , tickFormatMaxMin
25
26
;
26
27
axis
27
28
. scale ( scale )
@@ -106,7 +107,8 @@ nv.models.axis = function() {
106
107
. attr ( 'y' , - axis . tickPadding ( ) )
107
108
. attr ( 'text-anchor' , 'middle' )
108
109
. text ( function ( d , i ) {
109
- var v = fmt ( d ) ;
110
+ var formatter = tickFormatMaxMin || fmt ;
111
+ var v = formatter ( d ) ;
110
112
return ( '' + v ) . match ( 'NaN' ) ? '' : v ;
111
113
} ) ;
112
114
axisMaxMin . watchTransition ( renderWatch , 'min-max top' )
@@ -123,7 +125,7 @@ nv.models.axis = function() {
123
125
var rotateLabelsRule = '' ;
124
126
if ( rotateLabels % 360 ) {
125
127
//Reset transform on ticks so textHeight can be calculated correctly
126
- xTicks . attr ( 'transform' , '' ) ;
128
+ xTicks . attr ( 'transform' , '' ) ;
127
129
//Calculate the longest xTick width
128
130
xTicks . each ( function ( d , i ) {
129
131
var box = this . getBoundingClientRect ( ) ;
@@ -181,7 +183,8 @@ nv.models.axis = function() {
181
183
. attr ( 'transform' , rotateLabelsRule )
182
184
. style ( 'text-anchor' , rotateLabels ? ( rotateLabels % 360 > 0 ? 'start' : 'end' ) : 'middle' )
183
185
. text ( function ( d , i ) {
184
- var v = fmt ( d ) ;
186
+ var formatter = tickFormatMaxMin || fmt ;
187
+ var v = formatter ( d ) ;
185
188
return ( '' + v ) . match ( 'NaN' ) ? '' : v ;
186
189
} ) ;
187
190
axisMaxMin . watchTransition ( renderWatch , 'min-max bottom' )
@@ -216,7 +219,8 @@ nv.models.axis = function() {
216
219
. attr ( 'x' , axis . tickPadding ( ) )
217
220
. style ( 'text-anchor' , 'start' )
218
221
. text ( function ( d , i ) {
219
- var v = fmt ( d ) ;
222
+ var formatter = tickFormatMaxMin || fmt ;
223
+ var v = formatter ( d ) ;
220
224
return ( '' + v ) . match ( 'NaN' ) ? '' : v ;
221
225
} ) ;
222
226
axisMaxMin . watchTransition ( renderWatch , 'min-max right' )
@@ -260,7 +264,8 @@ nv.models.axis = function() {
260
264
. attr ( 'x' , - axis . tickPadding ( ) )
261
265
. attr ( 'text-anchor' , 'end' )
262
266
. text ( function ( d , i ) {
263
- var v = fmt ( d ) ;
267
+ var formatter = tickFormatMaxMin || fmt ;
268
+ var v = formatter ( d ) ;
264
269
return ( '' + v ) . match ( 'NaN' ) ? '' : v ;
265
270
} ) ;
266
271
axisMaxMin . watchTransition ( renderWatch , 'min-max right' )
@@ -331,9 +336,9 @@ nv.models.axis = function() {
331
336
and the arithmetic trick below solves that.
332
337
*/
333
338
return ! parseFloat ( Math . round ( d * 100000 ) / 1000000 ) && ( d !== undefined )
334
- } )
339
+ } )
335
340
. classed ( 'zero' , true ) ;
336
-
341
+
337
342
//store old scales for use in transitions on update
338
343
scale0 = scale . copy ( ) ;
339
344
@@ -364,6 +369,7 @@ nv.models.axis = function() {
364
369
ticks : { get : function ( ) { return ticks ; } , set : function ( _ ) { ticks = _ ; } } ,
365
370
width : { get : function ( ) { return width ; } , set : function ( _ ) { width = _ ; } } ,
366
371
fontSize : { get : function ( ) { return fontSize ; } , set : function ( _ ) { fontSize = _ ; } } ,
372
+ tickFormatMaxMin : { get : function ( ) { return tickFormatMaxMin ; } , set : function ( _ ) { tickFormatMaxMin = _ ; } } ,
367
373
368
374
// options that require extra logic in the setter
369
375
margin : { get : function ( ) { return margin ; } , set : function ( _ ) {
0 commit comments