Skip to content

Commit 71112e6

Browse files
committed
don't clip annotation text when clipping shouldn't do anything
1 parent e30d23a commit 71112e6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/components/annotations/draw.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

13 Bytes
Loading

0 commit comments

Comments
 (0)