Skip to content
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

Clean up constraint groups #2465

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
@@ -153,6 +153,8 @@ exports.plot = function(gd, data, layout, config) {

var fullLayout = gd._fullLayout;

var hasCartesian = fullLayout._has('cartesian');

// Legacy polar plots
if(!fullLayout._has('polar') && data && data[0] && data[0].r) {
Lib.log('Legacy polar charts are deprecated!');
@@ -426,16 +428,18 @@ exports.plot = function(gd, data, layout, config) {
addFrames,
drawFramework,
marginPushers,
marginPushersAgain,
positionAndAutorange,
subroutines.layoutStyles,
drawAxes,
marginPushersAgain
];
if(hasCartesian) seq.push(positionAndAutorange);
seq.push(subroutines.layoutStyles);
if(hasCartesian) seq.push(drawAxes);
seq.push(
drawData,
finalDraw,
initInteractions,
Plots.rehover,
Plots.previousPromises
];
);

// even if everything we did was synchronous, return a promise
// so that the caller doesn't care which route we took
@@ -2611,7 +2615,7 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) {
}

for(key in newContainer) {
if(!(key in oldContainer)) {
if(!(key in oldContainer || key.charAt(0) === '_' || typeof newContainer[key] === 'function')) {
valObject = getValObject(outerparts.concat(key));

if(valObjectCanBeDataArray(valObject) && Array.isArray(newContainer[key])) {
1 change: 1 addition & 0 deletions src/plots/cartesian/index.js
Original file line number Diff line number Diff line change
@@ -287,6 +287,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
if(hadCartesian && !hasCartesian) {
purgeSubplotLayers(oldFullLayout._cartesianlayer.selectAll('.subplot'), oldFullLayout);
oldFullLayout._defs.selectAll('.axesclip').remove();
delete oldFullLayout._axisConstraintGroups;
}
// otherwise look for subplots we need to remove
else if(oldSubplotList.cartesian) {
15 changes: 15 additions & 0 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
@@ -1261,6 +1261,21 @@ describe('Test plot api', function() {
.catch(fail)
.then(done);
});

it('can drop Cartesian while constraints are active', function(done) {
Plotly.newPlot(gd, [{x: [1, 2, 3], y: [1, 3, 2], z: [2, 3, 1]}], {xaxis: {scaleanchor: 'y'}})
.then(function() {
expect(gd._fullLayout._axisConstraintGroups).toBeDefined();
expect(gd._fullLayout.scene !== undefined).toBe(false);
return Plotly.restyle(gd, {type: 'scatter3d'});
})
.then(function() {
expect(gd._fullLayout._axisConstraintGroups).toBeUndefined();
expect(gd._fullLayout.scene !== undefined).toBe(true);
})
.catch(fail)
.then(done);
});
});

describe('Plotly.deleteTraces', function() {