Skip to content

Commit

Permalink
Merge pull request #405 from plotly/toggle-surfaceaxis
Browse files Browse the repository at this point in the history
dispose delaunayMeadh on scatter3d toggle [fixes #399]
  • Loading branch information
etpinard committed Apr 7, 2016
2 parents e8fc236 + ee35dc3 commit b5eed7e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/traces/scatter3d/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,15 @@ proto.dispose = function() {
this.scatterPlot.dispose();
}
if(this.errorBars) {
this.scene.remove(this.errorBars);
this.scene.glplot.remove(this.errorBars);
this.errorBars.dispose();
}
if(this.textMarkers) {
this.scene.glplot.remove(this.textMarkers);
this.textMarkers.dispose();
}
if(this.delaunayMesh) {
this.scene.glplot.remove(this.textMarkers);
this.scene.glplot.remove(this.delaunayMesh);
this.delaunayMesh.dispose();
}
};
Expand Down
28 changes: 27 additions & 1 deletion test/jasmine/tests/gl_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,17 @@ describe('Test gl plot interactions', function() {

beforeEach(function(done) {
gd = createGraphDiv();
Plotly.plot(gd, mock.data, mock.layout).then(function() {

var mockCopy = Lib.extendDeep({}, mock);

// lines, markers, text, error bars and surfaces each
// correspond to one glplot object
mockCopy.data[0].mode = 'lines+markers+text';
mockCopy.data[0].error_z = { value: 10 };
mockCopy.data[0].surfaceaxis = 2;
mockCopy.layout.showlegend = true;

Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {
delay(done);
});
});
Expand Down Expand Up @@ -190,6 +200,22 @@ describe('Test gl plot interactions', function() {
});
});

it('should be able to toggle visibility', function(done) {
var objects = gd._fullLayout.scene._scene.glplot.objects;

expect(objects.length).toEqual(5);

Plotly.restyle(gd, 'visible', 'legendonly').then(function() {
expect(objects.length).toEqual(0);

return Plotly.restyle(gd, 'visible', true);
}).then(function() {
expect(objects.length).toEqual(5);

done();
});
});

});

describe('gl2d plots', function() {
Expand Down

0 comments on commit b5eed7e

Please sign in to comment.