Skip to content

Commit

Permalink
fixes #3044 - don't try to makeCalcdata on visible:false traces
Browse files Browse the repository at this point in the history
... in Histogram.calc loop looking for isFirstVisible trace
  • Loading branch information
etpinard committed Dec 17, 2018
1 parent fdafdb9 commit 9eb9598
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
22 changes: 12 additions & 10 deletions src/traces/histogram/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,18 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {
var isFirstVisible = true;
for(i = 0; i < traces.length; i++) {
tracei = traces[i];
pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData);
allPos = Lib.concat(allPos, pos0);
delete tracei._autoBinFinished;
if(trace.visible === true) {
if(isFirstVisible) {
isFirstVisible = false;
}
else {
delete tracei._autoBin;
tracei._autoBinFinished = 1;
if(tracei.visible) {
pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData);
allPos = Lib.concat(allPos, pos0);
delete tracei._autoBinFinished;
if(trace.visible === true) {
if(isFirstVisible) {
isFirstVisible = false;
}
else {
delete tracei._autoBin;
tracei._autoBinFinished = 1;
}
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions test/jasmine/tests/histogram_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ describe('Test histogram', function() {
x: [1, 2, 3], type: 'histogram'
}, {
x: [1, 2, 3], type: 'histogram'
}, {
type: 'histogram'
}])
.then(function() {
assertTraceCount(3);
Expand Down Expand Up @@ -834,32 +836,33 @@ describe('Test histogram', function() {
Plotly.newPlot(gd, [
{type: 'histogram', x: [1]},
{type: 'histogram', x: [10, 10.1, 10.2, 10.3]},
{type: 'histogram', x: [20, 20, 20, 20, 20, 20, 20, 20, 20, 21]}
{type: 'histogram', x: [20, 20, 20, 20, 20, 20, 20, 20, 20, 21]},
{type: 'histogram'}
])
.then(function() {
_assertBinCenters([[0], [10], [20]]);
_assertBinCenters([[0], [10], [20], hidden]);
return Plotly.restyle(gd, 'visible', 'legendonly', [1, 2]);
})
.then(function() {
_assertBinCenters([[0], hidden, hidden]);
_assertBinCenters([[0], hidden, hidden, hidden]);
return Plotly.restyle(gd, 'visible', false, [1, 2]);
})
.then(function() {
_assertBinCenters([[1], hidden, hidden]);
_assertBinCenters([[1], hidden, hidden, hidden]);
return Plotly.restyle(gd, 'visible', [false, false, true]);
})
.then(function() {
_assertBinCenters([hidden, hidden, [20, 21]]);
_assertBinCenters([hidden, hidden, [20, 21], hidden]);
return Plotly.restyle(gd, 'visible', [false, true, false]);
})
.then(function() {
_assertBinCenters([hidden, [10.1, 10.3], hidden]);
_assertBinCenters([hidden, [10.1, 10.3], hidden, hidden]);
// only one trace is visible, despite traces being grouped
expect(gd._fullLayout.bargap).toBe(0);
return Plotly.restyle(gd, 'visible', ['legendonly', true, 'legendonly']);
})
.then(function() {
_assertBinCenters([hidden, [10], hidden]);
_assertBinCenters([hidden, [10], hidden, hidden]);
// legendonly traces still flip us back to gapped
expect(gd._fullLayout.bargap).toBe(0.2);
})
Expand Down

0 comments on commit 9eb9598

Please sign in to comment.