Skip to content

Commit 688516a

Browse files
committed
Fix carpet/legendonly interaction and isolate mode
1 parent 7e5e5ef commit 688516a

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/components/legend/draw.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ function handleClick(g, gd, numClicks) {
510510

511511
for(i = 0; i < fullData.length; i++) {
512512
allTraces.push(i);
513-
traceVisibility.push('legendonly');
513+
// For carpet traces in particular, push the current visibility. For others, legendonly:
514+
traceVisibility.push(Registry.traceIs(fullData[i], 'notLegendIsolatable') ? fullData[i].visible : 'legendonly');
514515
}
515516

516517
if(legendgroup === '') {
@@ -542,9 +543,7 @@ function handleClick(g, gd, numClicks) {
542543
}
543544
var visibilityUpdates = [];
544545
for(i = 0; i < fullData.length; i++) {
545-
if(!Registry.traceIs(fullData[i], 'notLegendIsolatable')) {
546-
visibilityUpdates.push(allTraces[i]);
547-
}
546+
visibilityUpdates.push(allTraces[i]);
548547
}
549548
Plotly.restyle(gd, 'visible', traceVisibility, visibilityUpdates);
550549
}

src/plots/plots.js

+4
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) {
709709
fullTrace = dataOut[carpetDependents[i]];
710710
var carpetAxis = carpetIndex[fullTrace.carpetid];
711711
fullTrace._carpet = carpetAxis;
712+
if(!carpetAxis || !carpetAxis.visible) {
713+
fullTrace.visible = false;
714+
continue;
715+
}
712716
fullTrace.xaxis = carpetAxis.xaxis;
713717
fullTrace.yaxis = carpetAxis.yaxis;
714718
}

src/traces/contourcarpet/calc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var lookupCarpet = require('../carpet/lookup_carpetid');
2828
// contour maps, because the makeBoundArray calls are too entangled
2929
module.exports = function calc(gd, trace) {
3030
var carpet = trace.carpet = lookupCarpet(gd, trace);
31-
if(!carpet || !carpet.visible) return;
31+
if(!carpet || !carpet.visible || carpet.visible === 'legendonly') return;
3232

3333
if(!trace.a || !trace.b) {
3434
// Look up the original incoming carpet data:

src/traces/contourcarpet/plot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function plotOne(gd, plotinfo, cd) {
4040
var carpet = trace.carpet = lookupCarpet(gd, trace);
4141
var carpetcd = gd.calcdata[carpet.index][0];
4242

43-
if(!carpet.visible) return;
43+
if(!carpet.visible || carpet.visible === 'legendonly') return;
4444

4545
var a = cd[0].a;
4646
var b = cd[0].b;

0 commit comments

Comments
 (0)