Skip to content

Commit 37439bf

Browse files
authored
Merge pull request #3890 from plotly/histogram2d-hover-fixup
Use correct index to lookup unique histogram2d y vals
2 parents 93af5d6 + d025741 commit 37439bf

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Diff for: src/traces/histogram2d/calc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ module.exports = function calc(gd, trace) {
149149
else if(xVals[n] !== xi) uniqueValsPerX = false;
150150
}
151151
if(uniqueValsPerY) {
152-
if(yVals[n] === undefined) yVals[n] = yi;
153-
else if(yVals[n] !== yi) uniqueValsPerY = false;
152+
if(yVals[m] === undefined) yVals[m] = yi;
153+
else if(yVals[m] !== yi) uniqueValsPerY = false;
154154
}
155155

156156
xGapLow = Math.min(xGapLow, xi - xEdges[n]);

Diff for: test/jasmine/tests/hover_label_test.js

+20
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,26 @@ describe('hover info', function() {
12251225
.then(done);
12261226
});
12271227

1228+
it('shows the data range when bins have multiple values (case 2)', function(done) {
1229+
var gd = createGraphDiv();
1230+
1231+
Plotly.plot(gd, [{
1232+
type: 'histogram2d',
1233+
x: ['a', 'b', 'c', 'a'],
1234+
y: [7, 2, 3, 7],
1235+
nbinsy: 3
1236+
}], {
1237+
width: 600,
1238+
height: 600
1239+
})
1240+
.then(function() {
1241+
_hover(gd, 250, 200);
1242+
assertHoverLabelContent({nums: ['x: b', 'y: 4 - 5', 'z: 0'].join('\n')});
1243+
})
1244+
.catch(failTest)
1245+
.then(done);
1246+
});
1247+
12281248
it('shows the exact data when bins have single values', function(done) {
12291249
var gd = createGraphDiv();
12301250

0 commit comments

Comments
 (0)