Skip to content

Commit dc3ab87

Browse files
committed
make gl2d clean-plot step more robust:
- delete old 2d scenes that don't nest any 'gl2d' traces, instead of deleting 2d scenes that have no corresp. axes in new fullLayout. - delete item in _plots, so that if a 'gl2d' -> 'cartesian' subplot conversion happens unhindered.
1 parent 5a83c84 commit dc3ab87

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/plots/gl2d/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
6969
var oldSceneKeys = Plots.getSubplotIds(oldFullLayout, 'gl2d');
7070

7171
for(var i = 0; i < oldSceneKeys.length; i++) {
72-
var oldSubplot = oldFullLayout._plots[oldSceneKeys[i]],
73-
xaName = oldSubplot.xaxis._name,
74-
yaName = oldSubplot.yaxis._name;
72+
var id = oldSceneKeys[i],
73+
oldSubplot = oldFullLayout._plots[id];
7574

76-
if(!!oldSubplot._scene2d && (!newFullLayout[xaName] || !newFullLayout[yaName])) {
75+
// old subplot wasn't gl2d; nothing to do
76+
if(!oldSubplot._scene2d) continue;
77+
78+
// if no traces are present, delete gl2d subplot
79+
var subplotData = Plots.getSubplotData(newFullData, 'gl2d', id);
80+
if(subplotData.length === 0) {
7781
oldSubplot._scene2d.destroy();
82+
delete oldFullLayout._plots[id];
7883
}
7984
}
8085
};

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ describe('Test gl plot interactions', function() {
539539
expect(gd._fullLayout._plots.xy._scene2d.glplot).toBeDefined();
540540

541541
Plots.cleanPlot([], {}, gd._fullData, gd._fullLayout);
542-
expect(gd._fullLayout._plots.xy._scene2d.glplot).toBe(null);
542+
expect(gd._fullLayout._plots).toEqual({});
543543

544544
done();
545545
});

0 commit comments

Comments
 (0)