Skip to content

Fix to enable switching modes using plotly react method on scattergl traces #3132

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 6 commits into from
Oct 24, 2018
Merged
Changes from 3 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
26 changes: 20 additions & 6 deletions src/traces/scattergl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,27 @@ function sceneUpdate(gd, subplot) {

// remove scene resources
scene.destroy = function destroy() {
if(scene.fill2d) scene.fill2d.destroy();
if(scene.scatter2d) scene.scatter2d.destroy();
if(scene.error2d) scene.error2d.destroy();
if(scene.line2d) scene.line2d.destroy();
if(scene.select2d) scene.select2d.destroy();
if((scene.fill2d) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking comment: We (me and @alexcjohnson ) would usually write these lines as

if(scene.fill2d && scene.fill2d.destroy) {
    scene.fill2d.destroy();
}

(scene.fill2d.destroy)) {
scene.fill2d.destroy();}
if((scene.scatter2d) &&
(scene.scatter2d.destroy)) {
scene.scatter2d.destroy();}
if((scene.error2d) &&
(scene.error2d.destroy)) {
scene.error2d.destroy();}
if((scene.line2d) &&
(scene.line2d.destroy)) {
scene.line2d.destroy();}
if((scene.select2d) &&
(scene.select2d.destroy)) {
scene.select2d.destroy();}
if(scene.glText) {
scene.glText.forEach(function(text) { text.destroy(); });
scene.glText.forEach(
Copy link
Contributor

Choose a reason for hiding this comment

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

and this thing as

scene.glText.forEach(function(text) {
    if(text.destroy) text.destroy();
});

function(text) {
if(text.destroy) text.destroy();
}
);
}

scene.lineOptions = null;
Expand Down