Skip to content

Commit 6c9ba1a

Browse files
committed
call ax.setScale in Annotations.drawOne
... which happens to be the first time it's called when annotations are present on autoranged axes on subplots w/o visible traces. This is important to avoid `transform:rotate(NaN)` errors as annotations require ax._offset to first-draw text to compute its bounds.
1 parent 440ca0d commit 6c9ba1a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/components/annotations/draw.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function drawOne(gd, index) {
6767
var xa = Axes.getFromId(gd, options.xref);
6868
var ya = Axes.getFromId(gd, options.yref);
6969

70+
if(xa) xa.setScale();
71+
if(ya) ya.setScale();
72+
7073
drawRaw(gd, options, index, false, xa, ya);
7174
}
7275

test/jasmine/tests/annotations_test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,28 @@ describe('annotations autorange', function() {
814814
.catch(failTest)
815815
.then(done);
816816
});
817+
818+
it('should not error out on subplots w/o visible traces', function(done) {
819+
Plotly.plot(gd, [{}], {
820+
annotations: [{
821+
x: 0.1,
822+
y: 0.1,
823+
text: 't',
824+
showarrow: false
825+
}, {
826+
x: 0.2,
827+
y: 0.3,
828+
text: 'a'
829+
}]
830+
})
831+
.then(function() {
832+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.099, 0.201], 1, 'x rng');
833+
expect(gd._fullLayout.yaxis.range).toBeCloseToArray([0.091, 0.335], 1, 'y rng');
834+
assertVisible([0, 1]);
835+
})
836+
.catch(failTest)
837+
.then(done);
838+
});
817839
});
818840

819841
describe('annotation clicktoshow', function() {

0 commit comments

Comments
 (0)