Skip to content

Commit

Permalink
replace selectAll().data([0]) with select() + .size()
Browse files Browse the repository at this point in the history
- to replace expensive querySelectorAll with plain querySelector
  • Loading branch information
etpinard committed Mar 13, 2018
1 parent d305564 commit 7d881f6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/plots/cartesian/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
};

exports.drawFramework = function(gd) {
var fullLayout = gd._fullLayout,
subplotData = makeSubplotData(gd);
var fullLayout = gd._fullLayout;
var subplotData = makeSubplotData(gd);

var subplotLayers = fullLayout._cartesianlayer.selectAll('.subplot')
.data(subplotData, Lib.identity);
Expand All @@ -327,6 +327,7 @@ exports.drawFramework = function(gd) {
plotinfo.overlays = [];

makeSubplotLayer(plotinfo);

// fill in list of overlay subplots
if(plotinfo.mainplot) {
var mainplot = fullLayout._plots[plotinfo.mainplot];
Expand Down Expand Up @@ -506,12 +507,11 @@ function removeSubplotExtras(subplotId, fullLayout) {
}

function joinLayer(parent, nodeType, className, dataVal) {
var layer = parent.selectAll('.' + className)
.data([dataVal || 0]);

layer.enter().append(nodeType)
.classed(className, true);

var sel = parent.select('.' + className);
var layer = sel.size() ?
sel :
parent.append(nodeType).classed(className, true);
if(dataVal) layer.datum(dataVal);
return layer;
}

Expand Down

0 comments on commit 7d881f6

Please sign in to comment.