Skip to content

Commit f587772

Browse files
committed
Add test for animating annotations
1 parent c532ca2 commit f587772

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/plots/cartesian/transition_axes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo
102102

103103
function updateLayoutObjs() {
104104
function redrawObjs(objArray, method) {
105-
var i;
106-
for(i = 0; i < objArray.length; i++) {
105+
for(var i = 0; i < objArray.length; i++) {
107106
method(gd, i);
108107
}
109108
}

test/jasmine/tests/annotations_test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,3 +1344,41 @@ describe('annotation effects', function() {
13441344
.then(done);
13451345
});
13461346
});
1347+
1348+
describe('animating annotations', function() {
1349+
var gd;
1350+
1351+
beforeEach(function() {
1352+
gd = createGraphDiv();
1353+
});
1354+
1355+
afterEach(destroyGraphDiv);
1356+
1357+
it('updates annoations when no axis update present', function(done) {
1358+
1359+
function assertAnnotations(expected) {
1360+
var texts = Plotly.d3.select(gd).selectAll('.annotation .annotation-text');
1361+
expect(expected.length).toEqual(texts.size());
1362+
1363+
texts.each(function(i) {
1364+
expect(Plotly.d3.select(this).text()).toEqual(expected[i]);
1365+
});
1366+
}
1367+
1368+
Plotly.plot(gd,
1369+
[{y: [1, 2, 3]}],
1370+
{annotations: [{text: 'hello'}]}
1371+
).then(function() {
1372+
assertAnnotations(['hello']);
1373+
1374+
return Plotly.animate(gd, [{
1375+
layout: {annotations: [{text: 'hi'}]}
1376+
}], {
1377+
frame: {redraw: false, duration: 0}
1378+
});
1379+
}).then(function() {
1380+
assertAnnotations(['hi']);
1381+
1382+
}).catch(failTest).then(done);
1383+
});
1384+
});

0 commit comments

Comments
 (0)