Skip to content

Fix relayout constrained axes + various multi-subplot perf improvements #2628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 14, 2018
2 changes: 1 addition & 1 deletion src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,7 @@ function _relayout(gd, aobj) {
var plen = p.parts.length;
// p.parts may end with an index integer if the property is an array
var pend = plen - 1;
while(pend > 0 && typeof p.parts[plen - 1] !== 'string') { pend--; }
while(pend > 0 && typeof p.parts[pend] !== 'string') pend--;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, nice catch!

// last property in chain (leaf node)
var pleaf = p.parts[pend];
// leaf plus immediate parent
Expand Down
33 changes: 33 additions & 0 deletions test/jasmine/tests/cartesian_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,39 @@ describe('axis zoom/pan and main plot zoom', function() {
.catch(failTest)
.then(done);
});

it('updates axis layout when the constraints require it', function(done) {
function _assert(xGridCnt) {
var xGrid = d3.select(gd).selectAll('.gridlayer > .x > path.xgrid');
expect(xGrid.size()).toEqual(xGridCnt);
}

Plotly.plot(gd, [{
x: [1, 1.5, 0, -1.5, -1, -1.5, 0, 1.5, 1],
y: [0, 1.5, 1, 1.5, 0, -1.5, -1, -1.5, 0],
line: {shape: 'spline'}
}], {
xaxis: {constrain: 'domain'},
yaxis: {scaleanchor: 'x'},
width: 700,
height: 500
})
.then(function() {
_assert(2);

return Plotly.relayout(gd, {
'xaxis.range[0]': 0,
'xaxis.range[1]': 1,
'yaxis.range[0]': 0,
'yaxis.range[1]': 1
});
})
.then(function() {
_assert(1);
})
.catch(failTest)
.then(done);
});
});

describe('Event data:', function() {
Expand Down
15 changes: 15 additions & 0 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,21 @@ describe('Test plot api', function() {
destroyGraphDiv();
});
});

it('should trigger calc on axis range updates when constraints are present', function() {
gd = mock({
data: [{
y: [1, 2, 1]
}],
layout: {
xaxis: {constrain: 'domain'},
yaxis: {scaleanchor: 'x'}
}
});

Plotly.relayout(gd, 'xaxis.range[0]', 0);
expect(gd.calcdata).toBeUndefined();
});
});

describe('Plotly.restyle subroutines switchboard', function() {
Expand Down