Skip to content

Commit d305564

Browse files
committed
perf makeSubplotData
- replace Object.keys + for-loop with for-in - replace slow subplots.indexOf
1 parent 03950d8 commit d305564

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/plots/cartesian/index.js

+12-19
Original file line numberDiff line numberDiff line change
@@ -347,29 +347,22 @@ exports.rangePlot = function(gd, plotinfo, cdSubplot) {
347347
};
348348

349349
function makeSubplotData(gd) {
350-
var fullLayout = gd._fullLayout,
351-
subplots = Object.keys(fullLayout._plots);
352-
353-
var subplotData = [],
354-
overlays = [];
355-
356-
for(var i = 0; i < subplots.length; i++) {
357-
var subplot = subplots[i],
358-
plotinfo = fullLayout._plots[subplot];
359-
360-
var xa = plotinfo.xaxis;
361-
var ya = plotinfo.yaxis;
362-
var xa2 = xa._mainAxis;
363-
var ya2 = ya._mainAxis;
350+
var fullLayout = gd._fullLayout;
351+
var subplotData = [];
352+
var overlays = [];
364353

354+
for(var k in fullLayout._plots) {
355+
var plotinfo = fullLayout._plots[k];
356+
var xa2 = plotinfo.xaxis._mainAxis;
357+
var ya2 = plotinfo.yaxis._mainAxis;
365358
var mainplot = xa2._id + ya2._id;
366-
if(mainplot !== subplot && subplots.indexOf(mainplot) !== -1) {
359+
360+
if(mainplot !== k && fullLayout._plots[mainplot]) {
367361
plotinfo.mainplot = mainplot;
368362
plotinfo.mainplotinfo = fullLayout._plots[mainplot];
369-
overlays.push(subplot);
370-
}
371-
else {
372-
subplotData.push(subplot);
363+
overlays.push(k);
364+
} else {
365+
subplotData.push(k);
373366
}
374367
}
375368

0 commit comments

Comments
 (0)