Skip to content

Commit 9fdf522

Browse files
committed
remove "alwaysSupplyDefaults" so visible: false does not contribute to stack config
1 parent 11b237d commit 9fdf522

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

src/plots/plots.js

-8
Original file line numberDiff line numberDiff line change
@@ -1181,14 +1181,6 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac
11811181

11821182
plots.supplyTransformDefaults(traceIn, traceOut, layout);
11831183
}
1184-
else if(_module && Registry.traceIs(traceOut, 'alwaysSupplyDefaults')) {
1185-
// Some types need *something* from supplyDefaults always, even if
1186-
// visible: false. Looking at you scatter: stack options even from
1187-
// hidden traces can control other traces in the stack.
1188-
// These types should bail out ASAP if visible is false.
1189-
// But we don't need any other cross-module attrs ^^ in this case.
1190-
_module.supplyDefaults(traceIn, traceOut, defaultColor, layout);
1191-
}
11921184

11931185
return traceOut;
11941186
};

src/traces/scatter/attributes.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ module.exports = {
9595
editType: 'calc',
9696
description: [
9797
'Only relevant when `stackgroup` is used, and only the first',
98-
'`orientation` found in the `stackgroup` will be used. Sets the',
98+
'`orientation` found in the `stackgroup` will be used - including',
99+
'if `visible` is *legendonly* but not if it is `false`. Sets the',
99100
'stacking direction. With *v* (*h*), the y (x) values of subsequent',
100101
'traces are added. Also affects the default value of `fill`.'
101102
].join(' ')
@@ -108,7 +109,8 @@ module.exports = {
108109
editType: 'calc',
109110
description: [
110111
'Only relevant when `stackgroup` is used, and only the first',
111-
'`groupnorm` found in the `stackgroup` will be used.',
112+
'`groupnorm` found in the `stackgroup` will be used - including',
113+
'if `visible` is *legendonly* but not if it is `false`.',
112114
'Sets the normalization for the sum of this `stackgroup`.',
113115
'With *fraction*, the value of each trace at each location is',
114116
'divided by the sum of all trace values at that location.',
@@ -125,7 +127,8 @@ module.exports = {
125127
editType: 'calc',
126128
description: [
127129
'Only relevant when `stackgroup` is used, and only the first',
128-
'`stackgaps` found in the `stackgroup` will be used.',
130+
'`stackgaps` found in the `stackgroup` will be used - including',
131+
'if `visible` is *legendonly* but not if it is `false`.',
129132
'Determines how we handle locations at which other traces in this',
130133
'group have data but this one does not.',
131134
'With *infer zero* we insert a zero at these locations.',

src/traces/scatter/defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2727
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
2828
}
2929

30-
var stackGroupOpts = handleStackDefaults(traceIn, traceOut, layout, coerce);
31-
3230
var len = handleXYDefaults(traceIn, traceOut, layout, coerce);
3331
if(!len) traceOut.visible = false;
3432

3533
if(!traceOut.visible) return;
3634

35+
var stackGroupOpts = handleStackDefaults(traceIn, traceOut, layout, coerce);
36+
3737
var defaultMode = !stackGroupOpts && (len < constants.PTS_LINESONLY) ?
3838
'lines+markers' : 'lines';
3939
coerce('text');

src/traces/scatter/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Scatter.name = 'scatter';
3636
Scatter.basePlotModule = require('../../plots/cartesian');
3737
Scatter.categories = [
3838
'cartesian', 'svg', 'symbols', 'errorBarsOK', 'showLegend', 'scatter-like',
39-
'zoomScale', 'alwaysSupplyDefaults'
39+
'zoomScale'
4040
];
4141
Scatter.meta = {
4242
description: [

test/jasmine/tests/scatter_test.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1049,11 +1049,16 @@ describe('stacked area', function() {
10491049
var xr = [2, 6];
10501050
checkRanges({
10511051
x: xr, x2: xr, x3: xr, x4: xr, x5: xr, x6: xr,
1052-
y: [0, 4.21], y2: [0, 5.26],
1053-
y3: [0, 1.08], y4: [0, 1.08], y5: [0, 105.26], y6: [0, 105.26]
1052+
// now we lose the explicit config from the bottom trace,
1053+
// which we kept when it was visible: 'legendonly'
1054+
y: [0, 4.21], y2: [0, 4.21],
1055+
y3: [0, 4.32], y4: [0, 1.08], y5: [0, 105.26], y6: [0, 5.26]
10541056
}, 'bottom trace visible: false');
10551057

1056-
return Plotly.restyle(gd, 'visible', false, [1, 4, 7, 10, 13, 16]);
1058+
// put the bottom traces back to legendonly so they still contribute
1059+
// config attributes, and hide the middles too
1060+
return Plotly.restyle(gd, 'visible', 'legendonly',
1061+
[0, 3, 6, 9, 12, 15, 1, 4, 7, 10, 13, 16]);
10571062
})
10581063
.then(function() {
10591064
var xr = [3, 5];
@@ -1072,6 +1077,21 @@ describe('stacked area', function() {
10721077
y: [0, 7.37], y2: [0, 7.37],
10731078
y3: [0, 1.08], y4: [0, 1.08], y5: [0, 105.26], y6: [0, 105.26]
10741079
}, 'top and bottom showing');
1080+
1081+
return Plotly.restyle(gd, {x: null, y: null}, [0, 3, 6, 9, 12, 15]);
1082+
})
1083+
.then(function() {
1084+
return Plotly.restyle(gd, 'visible', true, [1, 4, 7, 10, 13, 16]);
1085+
})
1086+
.then(function() {
1087+
var xr = [2, 6];
1088+
// an invalid trace (no data) implicitly has visible: false, and is
1089+
// equivalent to explicit visible: false in removing stack config.
1090+
checkRanges({
1091+
x: xr, x2: xr, x3: xr, x4: xr, x5: xr, x6: xr,
1092+
y: [0, 4.21], y2: [0, 4.21],
1093+
y3: [0, 4.32], y4: [0, 1.08], y5: [0, 105.26], y6: [0, 5.26]
1094+
}, 'bottom trace *implicit* visible: false');
10751095
})
10761096
.catch(failTest)
10771097
.then(done);

0 commit comments

Comments
 (0)