Skip to content

Use correct index to lookup unique histogram2d y vals #3890

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 1 commit into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/traces/histogram2d/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ module.exports = function calc(gd, trace) {
else if(xVals[n] !== xi) uniqueValsPerX = false;
}
if(uniqueValsPerY) {
if(yVals[n] === undefined) yVals[n] = yi;
else if(yVals[n] !== yi) uniqueValsPerY = false;
if(yVals[m] === undefined) yVals[m] = yi;
else if(yVals[m] !== yi) uniqueValsPerY = false;
}

xGapLow = Math.min(xGapLow, xi - xEdges[n]);
Expand Down
20 changes: 20 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,26 @@ describe('hover info', function() {
.then(done);
});

it('shows the data range when bins have multiple values (case 2)', function(done) {
var gd = createGraphDiv();

Plotly.plot(gd, [{
type: 'histogram2d',
x: ['a', 'b', 'c', 'a'],
y: [7, 2, 3, 7],
nbinsy: 3
}], {
width: 600,
height: 600
})
.then(function() {
_hover(gd, 250, 200);
assertHoverLabelContent({nums: ['x: b', 'y: 4 - 5', 'z: 0'].join('\n')});
})
.catch(failTest)
.then(done);
});

it('shows the exact data when bins have single values', function(done) {
var gd = createGraphDiv();

Expand Down