Skip to content

Commit 78bb3ed

Browse files
committed
fix multiple single-valued overlaid autobinned traces case
1 parent 34af401 commit 78bb3ed

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/traces/histogram/calc.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,12 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {
398398
* Returns the binSpec for the trace that sparked all this
399399
*/
400400
function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) {
401+
var fullLayout = gd._fullLayout;
401402
var overlaidTraceGroup = getConnectedHistograms(gd, trace);
402403
var pastThisTrace = false;
403404
var minSize = Infinity;
404405
var singleValuedTraces = [trace];
405-
var i, tracei;
406+
var i, tracei, binOpts;
406407

407408
// first collect all the:
408409
// - min bin size from all multi-valued traces
@@ -456,11 +457,16 @@ function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) {
456457
tracei = singleValuedTraces[i];
457458
var calendar = tracei[mainData + 'calendar'];
458459

459-
tracei._input[binAttr] = tracei[binAttr] = {
460+
var newBins = {
460461
start: pa.c2r(dataVals[i] - minSize / 2, 0, calendar),
461462
end: pa.c2r(dataVals[i] + minSize / 2, 0, calendar),
462463
size: minSize
463464
};
465+
466+
tracei._input[binAttr] = tracei[binAttr] = newBins;
467+
468+
binOpts = fullLayout._histogramBinOpts[tracei['_' + mainData + 'bingroup']];
469+
if(binOpts) Lib.extendFlat(binOpts, newBins);
464470
}
465471

466472
return trace[binAttr];

test/jasmine/tests/histogram_test.js

+8
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,14 @@ describe('Test histogram', function() {
693693
]);
694694
});
695695

696+
it('handles multiple single-valued overlaid autobinned traces', function() {
697+
var out = _calc({x: [1]}, [{x: [1]}], {barmode: 'overlay'}, true);
698+
699+
expect(out).toEqual([
700+
{p: 1, s: 1, b: 0, pts: [0], ph1: 1, ph0: 1, width1: 1, i: 0}
701+
]);
702+
});
703+
696704
it('handles multiple single-valued overlaid autobinned traces with different values', function() {
697705
var out = _calc({x: [null, 13, '', 13]}, [
698706
{x: [5]},

0 commit comments

Comments
 (0)