Skip to content

Commit 66c75db

Browse files
committed
adapt selectAll('g.subplot').each(d) data structure
- now 'd' is an array, and the subplot id is in d[0].
1 parent adc8514 commit 66c75db

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

src/plot_api/subroutines.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ function lsInner(gd) {
118118
// to put them
119119
var lowerBackgroundIDs = [];
120120
var lowerDomains = [];
121-
subplotSelection.each(function(subplot) {
121+
subplotSelection.each(function(d) {
122+
var subplot = d[0];
122123
var plotinfo = fullLayout._plots[subplot];
123124

124125
if(plotinfo.mainplot) {
@@ -161,7 +162,8 @@ function lsInner(gd) {
161162
fullLayout._plots[subplot].bg = d3.select(this);
162163
});
163164

164-
subplotSelection.each(function(subplot) {
165+
subplotSelection.each(function(d) {
166+
var subplot = d[0];
165167
var plotinfo = fullLayout._plots[subplot];
166168
var xa = plotinfo.xaxis;
167169
var ya = plotinfo.yaxis;

src/plots/cartesian/axes.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,9 @@ axes.doTicks = function(gd, arg, skipTitle) {
15261526
var fullLayout = gd._fullLayout;
15271527

15281528
if(arg === 'redraw') {
1529-
fullLayout._paper.selectAll('g.subplot').each(function(subplot) {
1530-
var plotinfo = fullLayout._plots[subplot];
1529+
fullLayout._paper.selectAll('g.subplot').each(function(d) {
1530+
var id = d[0];
1531+
var plotinfo = fullLayout._plots[id];
15311532
var xa = plotinfo.xaxis;
15321533
var ya = plotinfo.yaxis;
15331534

src/plots/cartesian/index.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -361,24 +361,24 @@ exports.drawFramework = function(gd) {
361361
.data(subplotData, String);
362362

363363
subplotLayers.enter().append('g')
364-
.attr('class', function(name) { return 'subplot ' + name; });
364+
.attr('class', function(d) { return 'subplot ' + d[0]; });
365365

366366
subplotLayers.order();
367367

368368
subplotLayers.exit()
369369
.call(purgeSubplotLayers, fullLayout);
370370

371-
subplotLayers.each(function(name) {
372-
var plotinfo = fullLayout._plots[name];
371+
subplotLayers.each(function(d) {
372+
var id = d[0];
373+
var plotinfo = fullLayout._plots[id];
373374

374375
plotinfo.plotgroup = d3.select(this);
375376
makeSubplotLayer(gd, plotinfo);
376377

377-
378378
// make separate drag layers for each subplot,
379379
// but append them to paper rather than the plot groups,
380380
// so they end up on top of the rest
381-
plotinfo.draglayer = ensureSingle(fullLayout._draggers, 'g', name);
381+
plotinfo.draglayer = ensureSingle(fullLayout._draggers, 'g', id);
382382
});
383383
};
384384

@@ -529,7 +529,9 @@ function makeSubplotLayer(gd, plotinfo) {
529529
if(!hasOnlyLargeSploms) {
530530
ensureSingleAndAddDatum(plotinfo.gridlayer, 'g', plotinfo.xaxis._id);
531531
ensureSingleAndAddDatum(plotinfo.gridlayer, 'g', plotinfo.yaxis._id);
532-
plotinfo.gridlayer.selectAll('g').sort(axisIds.idSort);
532+
plotinfo.gridlayer.selectAll('g')
533+
.map(function(d) { return d[0]; })
534+
.sort(axisIds.idSort);
533535
}
534536

535537
plotinfo.xlines
@@ -546,13 +548,13 @@ function purgeSubplotLayers(layers, fullLayout) {
546548

547549
var overlayIdsToRemove = {};
548550

549-
layers.each(function(subplotId) {
551+
layers.each(function(d) {
552+
var id = d[0];
550553
var plotgroup = d3.select(this);
551554

552555
plotgroup.remove();
553-
removeSubplotExtras(subplotId, fullLayout);
554-
555-
overlayIdsToRemove[subplotId] = true;
556+
removeSubplotExtras(id, fullLayout);
557+
overlayIdsToRemove[id] = true;
556558

557559
// do not remove individual axis <clipPath>s here
558560
// as other subplots may need them

test/jasmine/tests/splom_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ describe('@gl Test splom interactions:', function() {
457457
subplots.each(function(d, i) {
458458
var actual = this.children.length;
459459
var expected = typeof exp.innerSubplotNodeCnt === 'function' ?
460-
exp.innerSubplotNodeCnt(d, i) :
460+
exp.innerSubplotNodeCnt(d[0], i) :
461461
exp.innerSubplotNodeCnt;
462462
if(actual !== expected) {
463463
failedSubplots.push([d, actual, 'vs', expected].join(' '));

0 commit comments

Comments
 (0)