Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit adc8514

Browse filesBrowse files
committed
include info about things that reset subplot layers in d3-data
- to clean what need to be cleaned up in exit selection, instead of using granular and brittle old vs new plotinfo logic - axis.layer, overlays are currently include, we might want to include more things in it eventually,
1 parent a4d3597 commit adc8514
Copy full SHA for adc8514

File tree

Expand file treeCollapse file tree

1 file changed

+36
-24
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+36
-24
lines changed

‎src/plots/cartesian/index.js

Copy file name to clipboardExpand all lines: src/plots/cartesian/index.js
+36-24Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ exports.drawFramework = function(gd) {
358358
var subplotData = makeSubplotData(gd);
359359

360360
var subplotLayers = fullLayout._cartesianlayer.selectAll('.subplot')
361-
.data(subplotData, Lib.identity);
361+
.data(subplotData, String);
362362

363363
subplotLayers.enter().append('g')
364364
.attr('class', function(name) { return 'subplot ' + name; });
@@ -371,19 +371,9 @@ exports.drawFramework = function(gd) {
371371
subplotLayers.each(function(name) {
372372
var plotinfo = fullLayout._plots[name];
373373

374-
// keep ref to plot group
375374
plotinfo.plotgroup = d3.select(this);
376-
377-
// initialize list of overlay subplots
378-
plotinfo.overlays = [];
379-
380375
makeSubplotLayer(gd, plotinfo);
381376

382-
// fill in list of overlay subplots
383-
if(plotinfo.mainplot) {
384-
var mainplot = fullLayout._plots[plotinfo.mainplot];
385-
mainplot.overlays.push(plotinfo);
386-
}
387377

388378
// make separate drag layers for each subplot,
389379
// but append them to paper rather than the plot groups,
@@ -400,27 +390,49 @@ exports.rangePlot = function(gd, plotinfo, cdSubplot) {
400390

401391
function makeSubplotData(gd) {
402392
var fullLayout = gd._fullLayout;
403-
var subplotData = [];
404-
var overlays = [];
405-
406-
for(var k in fullLayout._plots) {
407-
var plotinfo = fullLayout._plots[k];
408-
var xa2 = plotinfo.xaxis._mainAxis;
409-
var ya2 = plotinfo.yaxis._mainAxis;
393+
var ids = fullLayout._subplots.cartesian;
394+
var len = ids.length;
395+
var subplotData = new Array(len);
396+
var i, j, id, plotinfo, xa, ya;
397+
398+
for(i = 0; i < len; i++) {
399+
id = ids[i];
400+
plotinfo = fullLayout._plots[id];
401+
xa = plotinfo.xaxis;
402+
ya = plotinfo.yaxis;
403+
404+
var xa2 = xa._mainAxis;
405+
var ya2 = ya._mainAxis;
410406
var mainplot = xa2._id + ya2._id;
407+
var mainplotinfo = fullLayout._plots[mainplot];
408+
plotinfo.overlays = [];
411409

412-
if(mainplot !== k && fullLayout._plots[mainplot]) {
410+
if(mainplot !== id && mainplotinfo) {
411+
// link 'main plot' ref in overlaying plotinfo
413412
plotinfo.mainplot = mainplot;
414-
plotinfo.mainplotinfo = fullLayout._plots[mainplot];
415-
overlays.push(k);
413+
plotinfo.mainplotinfo = mainplotinfo;
414+
// fill in list of overlaying subplots in 'main plot'
415+
mainplotinfo.overlays.push(plotinfo);
416416
} else {
417-
subplotData.push(k);
418417
plotinfo.mainplot = undefined;
418+
plotinfo.mainPlotinfo = undefined;
419419
}
420420
}
421421

422-
// main subplots before overlays
423-
subplotData = subplotData.concat(overlays);
422+
// use info about axis layer and overlaying pattern
423+
// to clean what need to be cleaned up in exit selection
424+
for(i = 0; i < len; i++) {
425+
id = ids[i];
426+
plotinfo = fullLayout._plots[id];
427+
xa = plotinfo.xaxis;
428+
ya = plotinfo.yaxis;
429+
430+
var d = [id, xa.layer, ya.layer, xa.overlaying || '', ya.overlaying || ''];
431+
for(j = 0; j < plotinfo.overlays.length; j++) {
432+
d.push(plotinfo.overlays[j].id);
433+
}
434+
subplotData[i] = d;
435+
}
424436

425437
return subplotData;
426438
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.