Skip to content

More optimization for cartesian subplots #2487

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
Mar 26, 2018
Merged
Changes from 1 commit
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
29 changes: 9 additions & 20 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,20 @@ exports.lsInner = function(gd) {

var xDomain = plotinfo.xaxis.domain;
var yDomain = plotinfo.yaxis.domain;
var plotgroupBgData = [];
var plotgroup = plotinfo.plotgroup;
var plotgroupBg;

if(overlappingDomain(xDomain, yDomain, lowerDomains)) {
plotgroupBgData = [0];
}
else {
var pgNode = plotgroup.node();
plotgroupBg = plotinfo.bg = Lib.ensureSingle(plotgroup, 'rect', 'bg');
pgNode.insertBefore(plotgroupBg.node(), pgNode.childNodes[0]);
} else {
plotgroupBg = plotgroup.select('rect,bg');
Copy link
Collaborator

Choose a reason for hiding this comment

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

rect.bg perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. I guess that means we have some untested code branches in there 😡

Copy link
Collaborator

Choose a reason for hiding this comment

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

we have some untested code branches in there

maybe, maybe not. rect,bg would delete all rect elements (are there any others? if not, then what you have there will work, it just won't be as efficient) and all bg elements (which don't exist)

Copy link
Contributor Author

@etpinard etpinard Mar 26, 2018

Choose a reason for hiding this comment

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

😌 yeah you're right,

image

this thing ⤴️ fails when commenting out this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 5307125

if(plotgroupBg.size()) plotgroupBg.remove();
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this if make a difference? Does it take a non-negligible time to remove an empty selection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that if did not improve things -> 🔪 in 5307125


lowerBackgroundIDs.push(subplot);
lowerDomains.push([xDomain, yDomain]);
}

// create the plot group backgrounds now, since
// they're all independent selections
var plotgroupBg = plotinfo.plotgroup.selectAll('.bg')
.data(plotgroupBgData);

plotgroupBg.enter().append('rect')
.classed('bg', true);

plotgroupBg.exit().remove();

plotgroupBg.each(function() {
plotinfo.bg = plotgroupBg;
var pgNode = plotinfo.plotgroup.node();
pgNode.insertBefore(this, pgNode.childNodes[0]);
});
});

// now create all the lower-layer backgrounds at once now that
Expand Down