8000 More single-value overlaid histogram fixes by etpinard · Pull Request #3935 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

More single-value overlaid histogram fixes #3935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix multiple single-valued overlaid autobinned traces case
  • Loading branch information
etpinard committed Jun 5, 2019
commit 78bb3eda76b4b63bee8d85a1049887d0538fdd0a
10 changes: 8 additions & 2 deletions src/traces/histogram/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,12 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {
* Returns the binSpec for the trace that sparked all this
*/
function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) {
var fullLayout = gd._fullLayout;
var overlaidTraceGroup = getConnectedHistograms(gd, trace);
var pastThisTrace = false;
var minSize = Infinity;
var singleValuedTraces = [trace];
var i, tracei;
var i, tracei, binOpts;

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

tracei._input[binAttr] = tracei[binAttr] = {
var newBins = {
start: pa.c2r(dataVals[i] - minSize / 2, 0, calendar),
end: pa.c2r(dataVals[i] + minSize / 2, 0, calendar),
size: minSize
};

tracei._input[binAttr] = tracei[binAttr] = newBins;

binOpts = fullLayout._histogramBinOpts[tracei['_' + mainData + 'bingroup']];
if(binOpts) Lib.extendFlat(binOpts, newBins);
}

return trace[binAttr];
Expand Down
8 changes: 8 additions & 0 deletions test/jasmine/tests/histogram_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,14 @@ describe('Test histogram', function() {
]);
});

it('handles multiple single-valued overlaid autobinned traces', function() {
var out = _calc({x: [1]}, [{x: [1]}], {barmode: 'overlay'}, true);

expect(out).toEqual([
{p: 1, s: 1, b: 0, pts: [0], ph1: 1, ph0: 1, width1: 1, i: 0}
]);
});

it('handles multiple single-valued overlaid autobinned traces with different values', function() {
var out = _calc({x: [null, 13, '', 13]}, [
{x: [5]},
Expand Down
0