@@ -218,12 +218,11 @@ function makePadFn(ax, max) {
218
218
if ( axReverse ) max = ! max ;
219
219
}
220
220
221
- extrappad = adjustPadForInsideLabelsOnAnchorAxis ( extrappad , ax , max ) ;
222
- extrappad = adjustPadForInsideLabelsOnThisAxis ( extrappad , ax , max ) ;
221
+ var A = padInsideLabelsOnAnchorAxis ( ax , max ) ;
222
+ var B = padInsideLabelsOnThisAxis ( ax , max ) ;
223
223
224
- var pad0 = 0 ;
225
- pad0 = adjustPadForInsideLabelsOnAnchorAxis ( pad0 , ax , max ) ;
226
- pad0 = adjustPadForInsideLabelsOnThisAxis ( pad0 , ax , max ) ;
224
+ var zero = Math . max ( A , B ) ;
225
+ extrappad = Math . max ( zero , extrappad ) ;
227
226
228
227
// domain-constrained axes: base extrappad on the unconstrained
229
228
// domain so it's consistent as the domain changes
@@ -232,18 +231,18 @@ function makePadFn(ax, max) {
232
231
( ax . domain [ 1 ] - ax . domain [ 0 ] ) ;
233
232
}
234
233
235
- return function getPad ( pt ) { return pt . pad + ( pt . extrapad ? extrappad : pad0 ) ; } ;
234
+ return function getPad ( pt ) { return pt . pad + ( pt . extrapad ? extrappad : zero ) ; } ;
236
235
}
237
236
238
237
var TEXTPAD = 3 ;
239
238
240
- function adjustPadForInsideLabelsOnThisAxis ( pad , ax , max ) {
239
+ function padInsideLabelsOnThisAxis ( ax , max ) {
241
240
var ticklabelposition = ax . ticklabelposition || '' ;
242
241
var has = function ( str ) {
243
242
return ticklabelposition . indexOf ( str ) !== - 1 ;
244
243
} ;
245
244
246
- if ( ! has ( 'inside' ) ) return pad ;
245
+ if ( ! has ( 'inside' ) ) return 0 ;
247
246
var isTop = has ( 'top' ) ;
248
247
var isLeft = has ( 'left' ) ;
249
248
var isRight = has ( 'right' ) ;
@@ -254,27 +253,26 @@ function adjustPadForInsideLabelsOnThisAxis(pad, ax, max) {
254
253
( max && ( isLeft || isBottom ) ) ||
255
254
( ! max && ( isRight || isTop ) )
256
255
) {
257
- return pad ;
256
+ return 0 ;
258
257
}
259
258
260
259
// increase padding to make more room for inside tick labels of the axis
261
260
var fontSize = ax . tickfont ? ax . tickfont . size : 12 ;
262
261
var isX = ax . _id . charAt ( 0 ) === 'x' ;
263
- var morePad = ( isX ? 1.2 : 0.6 ) * fontSize ;
262
+ var pad = ( isX ? 1.2 : 0.6 ) * fontSize ;
264
263
265
264
if ( isAligned ) {
266
- morePad *= 2 ;
267
- morePad += ( ax . tickwidth || 0 ) / 2 ;
265
+ pad *= 2 ;
266
+ pad += ( ax . tickwidth || 0 ) / 2 ;
268
267
}
269
268
270
- morePad += TEXTPAD ;
271
-
272
- pad = Math . max ( pad , morePad ) ;
269
+ pad += TEXTPAD ;
273
270
274
271
return pad ;
275
272
}
276
273
277
- function adjustPadForInsideLabelsOnAnchorAxis ( pad , ax , max ) {
274
+ function padInsideLabelsOnAnchorAxis ( ax , max ) {
275
+ var pad = 0 ;
278
276
var anchorAxis = ( ax . _anchorAxis || { } ) ;
279
277
if ( ( anchorAxis . ticklabelposition || '' ) . indexOf ( 'inside' ) !== - 1 ) {
280
278
// increase padding to make more room for inside tick labels of the counter axis
@@ -291,7 +289,6 @@ function adjustPadForInsideLabelsOnAnchorAxis(pad, ax, max) {
291
289
) ) {
292
290
var isX = ax . _id . charAt ( 0 ) === 'x' ;
293
291
294
- var morePad = 0 ;
295
292
if ( anchorAxis . _vals ) {
296
293
var rad = Lib . deg2rad ( anchorAxis . _tickAngles [ anchorAxis . _id + 'tick' ] || 0 ) ;
297
294
var cosA = Math . abs ( Math . cos ( rad ) ) ;
@@ -303,22 +300,20 @@ function adjustPadForInsideLabelsOnAnchorAxis(pad, ax, max) {
303
300
var w = t . bb . width ;
304
301
var h = t . bb . height ;
305
302
306
- morePad = Math . max ( morePad , isX ?
303
+ pad = Math . max ( pad , isX ?
307
304
Math . max ( w * cosA , h * sinA ) :
308
305
Math . max ( h * cosA , w * sinA )
309
306
) ;
310
307
311
308
// add extra pad around label
312
- morePad += 3 ;
309
+ pad += 3 ;
313
310
}
314
311
} ) ;
315
312
}
316
313
317
314
if ( anchorAxis . ticks === 'inside' && anchorAxis . ticklabelposition === 'inside' ) {
318
- morePad += anchorAxis . ticklen || 0 ;
315
+ pad += anchorAxis . ticklen || 0 ;
319
316
}
320
-
321
- pad = Math . max ( pad , morePad ) ;
322
317
}
323
318
}
324
319
0 commit comments