@@ -217,7 +217,7 @@ function makePadFn(fullLayout, ax, max) {
217
217
218
218
var zero = 0 ;
219
219
if ( ! isLinked ( fullLayout , ax . _id ) ) {
220
- zero = padInsideLabelsOnAnchorAxis ( ax , max ) ;
220
+ zero = padInsideLabelsOnAnchorAxis ( fullLayout , ax , max ) ;
221
221
}
222
222
extrappad = Math . max ( zero , extrappad ) ;
223
223
@@ -236,45 +236,54 @@ function makePadFn(fullLayout, ax, max) {
236
236
237
237
var TEXTPAD = 3 ;
238
238
239
- function padInsideLabelsOnAnchorAxis ( ax , max ) {
239
+ function padInsideLabelsOnAnchorAxis ( fullLayout , ax , max ) {
240
240
var pad = 0 ;
241
- var anchorAxis = ax . _anchorAxis || { } ;
242
- if ( ( anchorAxis . ticklabelposition || '' ) . indexOf ( 'inside' ) !== - 1 ) {
243
- // increase padding to make more room for inside tick labels of the counter axis
244
- if ( (
245
- ! max && (
246
- anchorAxis . side === 'left' ||
247
- anchorAxis . side === 'bottom'
248
- )
249
- ) || (
250
- max && (
251
- anchorAxis . side === 'top' ||
252
- anchorAxis . side === 'right'
253
- )
254
- ) ) {
255
- var isX = ax . _id . charAt ( 0 ) === 'x' ;
256
-
257
- if ( anchorAxis . _vals ) {
258
- var rad = Lib . deg2rad ( anchorAxis . _tickAngles [ anchorAxis . _id + 'tick' ] || 0 ) ;
259
- var cosA = Math . abs ( Math . cos ( rad ) ) ;
260
- var sinA = Math . abs ( Math . sin ( rad ) ) ;
261
-
262
- // use bounding boxes
263
- anchorAxis . _vals . forEach ( function ( t ) {
264
- if ( t . bb ) {
265
- var w = 2 * TEXTPAD + t . bb . width ;
266
- var h = 2 * TEXTPAD + t . bb . height ;
267
-
268
- pad = Math . max ( pad , isX ?
269
- Math . max ( w * cosA , h * sinA ) :
270
- Math . max ( h * cosA , w * sinA )
271
- ) ;
241
+
242
+ var isX = ax . _id . charAt ( 0 ) === 'x' ;
243
+
244
+ for ( var subplot in fullLayout . _plots ) {
245
+ var plotinfo = fullLayout . _plots [ subplot ] ;
246
+
247
+ if ( ax . _id !== plotinfo . xaxis . _id && ax . _id !== plotinfo . yaxis . _id ) continue ;
248
+
249
+ var anchorAxis = ( isX ? plotinfo . yaxis : plotinfo . xaxis ) || { } ;
250
+
251
+ if ( ( anchorAxis . ticklabelposition || '' ) . indexOf ( 'inside' ) !== - 1 ) {
252
+ // increase padding to make more room for inside tick labels of the counter axis
253
+ if ( (
254
+ ! max && (
255
+ anchorAxis . side === 'left' ||
256
+ anchorAxis . side === 'bottom'
257
+ )
258
+ ) || (
259
+ max && (
260
+ anchorAxis . side === 'top' ||
261
+ anchorAxis . side === 'right'
262
+ )
263
+ ) ) {
264
+ if ( anchorAxis . _vals ) {
265
+ var rad = Lib . deg2rad ( anchorAxis . _tickAngles [ anchorAxis . _id + 'tick' ] || 0 ) ;
266
+ var cosA = Math . abs ( Math . cos ( rad ) ) ;
267
+ var sinA = Math . abs ( Math . sin ( rad ) ) ;
268
+
269
+ // use bounding boxes
270
+ for ( var i = 0 ; i < anchorAxis . _vals . length ; i ++ ) {
271
+ var t = anchorAxis . _vals [ i ] ;
272
+ if ( t . bb ) {
273
+ var w = 2 * TEXTPAD + t . bb . width ;
274
+ var h = 2 * TEXTPAD + t . bb . height ;
275
+
276
+ pad = Math . max ( pad , isX ?
277
+ Math . max ( w * cosA , h * sinA ) :
278
+ Math . max ( h * cosA , w * sinA )
279
+ ) ;
280
+ }
272
281
}
273
- } ) ;
274
- }
282
+ }
275
283
276
- if ( anchorAxis . ticks === 'inside' && anchorAxis . ticklabelposition === 'inside' ) {
277
- pad += anchorAxis . ticklen || 0 ;
284
+ if ( anchorAxis . ticks === 'inside' && anchorAxis . ticklabelposition === 'inside' ) {
285
+ pad += anchorAxis . ticklen || 0 ;
286
+ }
278
287
}
279
288
}
280
289
}
0 commit comments