@@ -3058,6 +3058,7 @@ axes.drawLabels = function(gd, ax, opts) {
3058
3058
if ( ! ticklabeloverflow || ticklabeloverflow === 'allow' ) return ;
3059
3059
3060
3060
var hideOverflow = ticklabeloverflow . indexOf ( 'hide' ) !== - 1 ;
3061
+ var pushOverflow = ticklabeloverflow . indexOf ( 'push' ) !== - 1 ;
3061
3062
3062
3063
var isX = ax . _id . charAt ( 0 ) === 'x' ;
3063
3064
// div positions
@@ -3087,18 +3088,22 @@ axes.drawLabels = function(gd, ax, opts) {
3087
3088
3088
3089
if ( mathjaxGroup . empty ( ) ) {
3089
3090
var bb = Drawing . bBox ( thisLabel . node ( ) ) ;
3090
- var adjust = false ;
3091
+ var adjust = '' ;
3091
3092
if ( isX ) {
3092
- if ( bb . right > max ) adjust = true ;
3093
- else if ( bb . left < min ) adjust = true ;
3093
+ if ( bb . right > max ) adjust += 'right' ;
3094
+ else if ( bb . left < min ) adjust += 'left' ;
3094
3095
} else {
3095
- if ( bb . bottom > max ) adjust = true ;
3096
- else if ( bb . top + ( ax . tickangle ? 0 : d . fontSize / 4 ) < min ) adjust = true ;
3096
+ if ( bb . bottom > max ) adjust += 'top' ;
3097
+ else if ( bb . top + ( ax . tickangle ? 0 : d . fontSize / 4 ) < min ) adjust += 'bottom' ;
3097
3098
}
3098
3099
3099
3100
var t = thisLabel . select ( 'text' ) ;
3100
3101
if ( adjust ) {
3101
3102
if ( hideOverflow ) t . style ( 'opacity' , 0 ) ; // hidden
3103
+ else if ( pushOverflow ) {
3104
+ if ( adjust . indexOf ( 'left' ) !== - 1 ) t . attr ( 'text-anchor' , 'start' ) ;
3105
+ if ( adjust . indexOf ( 'right' ) !== - 1 ) t . attr ( 'text-anchor' , 'end' ) ;
3106
+ }
3102
3107
} else {
3103
3108
t . style ( 'opacity' , 1 ) ; // visible
3104
3109
0 commit comments