Skip to content

Commit 7d881f6

Browse files
committed
replace selectAll().data([0]) with select() + .size()
- to replace expensive querySelectorAll with plain querySelector
1 parent d305564 commit 7d881f6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/plots/cartesian/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
303303
};
304304

305305
exports.drawFramework = function(gd) {
306-
var fullLayout = gd._fullLayout,
307-
subplotData = makeSubplotData(gd);
306+
var fullLayout = gd._fullLayout;
307+
var subplotData = makeSubplotData(gd);
308308

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

329329
makeSubplotLayer(plotinfo);
330+
330331
// fill in list of overlay subplots
331332
if(plotinfo.mainplot) {
332333
var mainplot = fullLayout._plots[plotinfo.mainplot];
@@ -506,12 +507,11 @@ function removeSubplotExtras(subplotId, fullLayout) {
506507
}
507508

508509
function joinLayer(parent, nodeType, className, dataVal) {
509-
var layer = parent.selectAll('.' + className)
510-
.data([dataVal || 0]);
511-
512-
layer.enter().append(nodeType)
513-
.classed(className, true);
514-
510+
var sel = parent.select('.' + className);
511+
var layer = sel.size() ?
512+
sel :
513+
parent.append(nodeType).classed(className, true);
514+
if(dataVal) layer.datum(dataVal);
515515
return layer;
516516
}
517517

0 commit comments

Comments
 (0)