@@ -118,15 +118,18 @@ function drawOne(gd, index) {
118118 . call ( Color . stroke , options . bordercolor )
119119 . call ( Color . fill , options . bgcolor ) ;
120120
121+ var isSizeConstrained = options . width || options . height ;
122+
121123 var annClipID = 'clip' + fullLayout . _uid + '_ann' + index ;
122124 var annTextClip = fullLayout . _defs . select ( '.clips' )
123125 . selectAll ( '#' + annClipID )
124- . data ( [ 0 ] ) ;
126+ . data ( isSizeConstrained ? [ 0 ] : [ ] ) ;
125127
126128 annTextClip . enter ( ) . append ( 'clipPath' )
127129 . classed ( 'annclip' , true )
128130 . attr ( 'id' , annClipID )
129131 . append ( 'rect' ) ;
132+ annTextClip . exit ( ) . remove ( ) ;
130133
131134 var font = options . font ;
132135
@@ -326,7 +329,7 @@ function drawOne(gd, index) {
326329 x : borderfull + xShift - 1 ,
327330 y : borderfull + yShift
328331 } )
329- . call ( Drawing . setClipUrl , annClipID ) ;
332+ . call ( Drawing . setClipUrl , isSizeConstrained ? annClipID : null ) ;
330333 }
331334 else {
332335 var texty = borderfull + yShift - anntextBB . top ,
@@ -335,7 +338,7 @@ function drawOne(gd, index) {
335338 x : textx ,
336339 y : texty
337340 } )
338- . call ( Drawing . setClipUrl , annClipID ) ;
341+ . call ( Drawing . setClipUrl , isSizeConstrained ? annClipID : null ) ;
339342 annText . selectAll ( 'tspan.line' ) . attr ( { y : texty , x : textx } ) ;
340343 }
341344
0 commit comments