8000 fix #1325 - animating multiple axes · plotly/plotly.js@e036fea · GitHub
[go: up one dir, main page]

Skip to content

Commit e036fea

Browse files
committed
fix #1325 - animating multiple axes
1 parent f90f079 commit e036fea

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

src/plots/cartesian/transition_axes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var Plotly = require('../../plotly');
1515
var Registry = require('../../registry');
1616
var Drawing = require('../../components/drawing');
1717
var Axes = require('./axes');
18-
var axisRegex = /((x|y)([2-9]|[1-9][0-9]+)?)axis$/;
18+
var axisRegex = require('./constants').attrRegex;
1919

2020
module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCompleteCallback) {
2121
var fullLayout = gd._fullLayout;
@@ -29,8 +29,8 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo
2929
attrList = ai.split('.');
3030
match = attrList[0].match(axisRegex);
3131
if(match) {
32-
var axisLetter = match[1];
33-
var axisName = axisLetter + 'axis';
32+
var axisLetter = ai.charAt(0);
33+
var axisName = attrList[0];
3434
axis = fullLayout[axisName];
3535
update = {};
3636

test/jasmine/tests/animate_test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,51 @@ describe('Animate API details', function() {
707707
});
708708
});
709709

710+
describe('Animating multiple axes', function() {
711+
'use strict';
712+
var gd;
713+
714+
beforeEach(function() {
715+
gd = createGraphDiv();
716+
});
717+
718+
afterEach(function() {
719+
Plotly.purge(gd);
720+
destroyGraphDiv();
721+
});
722+
723+
it('updates ranges of secondary axes', function(done) {
724+
Plotly.plot(gd, [
725+
{y: [1, 2, 3]},
726+
{y: [1, 2, 3], yaxis: 'y2'}
727+
], {
728+
yaxis: {range: [0, 5]},
729+
yaxis2: {range: [-1, 4]}
730+
})
731+
.then(function() {
732+
expect(gd._fullLayout.yaxis.range).toEqual([0, 5]);
733+
expect(gd._fullLayout.yaxis2.range).toEqual([-1, 4]);
734+
735+
return Plotly.animate(gd, [
736+
{layout: {'yaxis.range': [2, 3]}},
737+
{layout: {'yaxis2.range': [1, 2]}}
738+
], {
739+
// TODO: if the durations are the same, yaxis.range gets some
740+
// random endpoint, often close to what it's supposed to be but
741+
// sometimes very far away.
742+
frame: {redraw: false, duration: 60},
743+
transition: {duration: 30}
744+
});
745+
})
746+
.then(function() {
747+
expect(gd._fullLayout.yaxis.range).toEqual([2, 3]);
748+
expect(gd._fullLayout.yaxis2.range).toEqual([1, 2]);
749+
})
750+
.catch(fail)
751+
.then(done);
752+
});
753+
});
754+
710755
describe('non-animatable fallback', function() {
711756
'use strict';
712757
var gd;

0 commit comments

Comments
 (0)
0