Skip to content

Commit c0a97bd

Browse files
authoredMar 9, 2018
Merge pull request #2465 from plotly/drop-constraints
Clean up constraint groups
2 parents ae7ba10 + f32dde4 commit c0a97bd

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed
 

‎src/plot_api/plot_api.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ exports.plot = function(gd, data, layout, config) {
153153

154154
var fullLayout = gd._fullLayout;
155155

156+
var hasCartesian = fullLayout._has('cartesian');
157+
156158
// Legacy polar plots
157159
if(!fullLayout._has('polar') && data && data[0] && data[0].r) {
158160
Lib.log('Legacy polar charts are deprecated!');
@@ -426,16 +428,18 @@ exports.plot = function(gd, data, layout, config) {
426428
addFrames,
427429
drawFramework,
428430
marginPushers,
429-
marginPushersAgain,
430-
positionAndAutorange,
431-
subroutines.layoutStyles,
432-
drawAxes,
431+
marginPushersAgain
432+
];
433+
if(hasCartesian) seq.push(positionAndAutorange);
434+
seq.push(subroutines.layoutStyles);
435+
if(hasCartesian) seq.push(drawAxes);
436+
seq.push(
433437
drawData,
434438
finalDraw,
435439
initInteractions,
436440
Plots.rehover,
437441
Plots.previousPromises
438-
];
442+
);
439443

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

26132617
for(key in newContainer) {
2614-
if(!(key in oldContainer)) {
2618+
if(!(key in oldContainer || key.charAt(0) === '_' || typeof newContainer[key] === 'function')) {
26152619
valObject = getValObject(outerparts.concat(key));
26162620

26172621
if(valObjectCanBeDataArray(valObject) && Array.isArray(newContainer[key])) {

‎src/plots/cartesian/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
287287
if(hadCartesian && !hasCartesian) {
288288
purgeSubplotLayers(oldFullLayout._cartesianlayer.selectAll('.subplot'), oldFullLayout);
289289
oldFullLayout._defs.selectAll('.axesclip').remove();
290+
delete oldFullLayout._axisConstraintGroups;
290291
}
291292
// otherwise look for subplots we need to remove
292293
else if(oldSubplotList.cartesian) {

‎test/jasmine/tests/plot_api_test.js

+15
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,21 @@ describe('Test plot api', function() {
12611261
.catch(fail)
12621262
.then(done);
12631263
});
1264+
1265+
it('can drop Cartesian while constraints are active', function(done) {
1266+
Plotly.newPlot(gd, [{x: [1, 2, 3], y: [1, 3, 2], z: [2, 3, 1]}], {xaxis: {scaleanchor: 'y'}})
1267+
.then(function() {
1268+
expect(gd._fullLayout._axisConstraintGroups).toBeDefined();
1269+
expect(gd._fullLayout.scene !== undefined).toBe(false);
1270+
return Plotly.restyle(gd, {type: 'scatter3d'});
1271+
})
1272+
.then(function() {
1273+
expect(gd._fullLayout._axisConstraintGroups).toBeUndefined();
1274+
expect(gd._fullLayout.scene !== undefined).toBe(true);
1275+
})
1276+
.catch(fail)
1277+
.then(done);
1278+
});
12641279
});
12651280

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

0 commit comments

Comments
 (0)
Please sign in to comment.