@@ -707,7 +707,9 @@ function appendBarText(gd, plotinfo, bar, cd, i, x0, x1, y0, y1, r, overhead, op
707707 transform = toMoveOutsideBar ( x0 , x1 , y0 , y1 , textBB , {
708708 isHorizontal : isHorizontal ,
709709 constrained : constrained ,
710- angle : angle
710+ angle : angle ,
711+ xa : xa , // Pass the X-Axis configuration
712+ ya : ya // Pass the Y-Axis configuration
711713 } ) ;
712714 } else {
713715 constrained = trace . constraintext === 'both' || trace . constraintext === 'inside' ;
@@ -957,12 +959,32 @@ function toMoveOutsideBar(x0, x1, y0, y1, textBB, opts) {
957959 var anchorX = 0 ;
958960 var anchorY = 0 ;
959961
962+ // Dynamic presentation safety buffer to clear tilted axis tick labels
963+ var axisPad = 0 ;
964+ if ( ! isHorizontal && opts . xa && opts . xa . side === 'top' ) {
965+ if ( opts . xa . _g && opts . xa . _g . node ( ) ) {
966+ var axisBB = opts . xa . _g . node ( ) . getBBox ( ) ;
967+ if ( axisBB && axisBB . height > 0 ) {
968+ // Shift exactly past the bounding height of the tilted labels plus a clean 6px visual gap
969+ axisPad = axisBB . height + 6 ;
970+ }
971+ }
972+ } else if ( isHorizontal && opts . ya && opts . ya . side === 'right' ) {
973+ if ( opts . ya . _g && opts . ya . _g . node ( ) ) {
974+ var axisBB = opts . ya . _g . node ( ) . getBBox ( ) ;
975+ if ( axisBB && axisBB . width > 0 ) {
976+ // Shift exactly past the bounding width of the side labels plus a clean 6px visual gap
977+ axisPad = axisBB . width + 6 ;
978+ }
979+ }
980+ }
981+
960982 var dir = isHorizontal ? dirSign ( x1 , x0 ) : dirSign ( y0 , y1 ) ;
961983 if ( isHorizontal ) {
962- targetX = x1 - dir * textpad ;
984+ targetX = x1 - dir * ( textpad + axisPad ) ;
963985 anchorX = dir * extrapad ;
964986 } else {
965- targetY = y1 + dir * textpad ;
987+ targetY = y1 + dir * ( textpad + axisPad ) ;
966988 anchorY = - dir * extrapad ;
967989 }
968990
0 commit comments