@@ -3016,15 +3016,14 @@ axes.drawLabels = function(gd, ax, opts) {
30163016 }
30173017
30183018 ax . _hideOutOfRangeInsideTickLabels = undefined ;
3019- if ( ( ax . ticklabelposition || '' ) . indexOf ( 'inside' ) !== - 1 && ax . _subplotsWith ) {
3019+ if ( ( ax . ticklabelposition || '' ) . indexOf ( 'inside' ) !== - 1 ) {
30203020 ax . _hideOutOfRangeInsideTickLabels = function ( ) {
30213021 // hide inside tick labels that go outside axis end points
3022+ var p0 = ax . l2p ( ax . _rl [ 0 ] ) ;
3023+ var p1 = ax . l2p ( ax . _rl [ 1 ] ) ;
30223024
3023- var gridLayer = fullLayout . _cartesianlayer
3024- . select ( '.subplot.' + ax . _subplotsWith [ 0 ] ) // is it the best way to get?
3025- . select ( '.gridlayer' ) ;
3026-
3027- var gridBb = Drawing . bBox ( gridLayer . node ( ) ) ;
3025+ var min = Math . min ( p0 , p1 ) + ax . _offset ;
3026+ var max = Math . max ( p0 , p1 ) + ax . _offset ;
30283027
30293028 var isX = ax . _id . charAt ( 0 ) === 'x' ;
30303029
@@ -3036,11 +3035,11 @@ axes.drawLabels = function(gd, ax, opts) {
30363035 var bb = Drawing . bBox ( thisLabel . node ( ) ) ;
30373036 var hide = false ;
30383037 if ( isX ) {
3039- if ( bb . right > gridBb . right ) hide = true ;
3040- else if ( bb . left < gridBb . left ) hide = true ;
3038+ if ( bb . right > max ) hide = true ;
3039+ else if ( bb . left < min ) hide = true ;
30413040 } else {
3042- if ( bb . bottom > gridBb . bottom ) hide = true ;
3043- else if ( bb . top < gridBb . top ) hide = true ;
3041+ if ( bb . bottom > max ) hide = true ;
3042+ else if ( bb . top < min ) hide = true ;
30443043 }
30453044 if ( hide ) thisLabel . select ( 'text' ) . style ( { opacity : 0 } ) ;
30463045 } // TODO: hide mathjax?
0 commit comments