From d025741b86ad7fe2136c0b99d19f013d1924e836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 22 May 2019 17:23:13 -0400 Subject: [PATCH] use correct index to lookup unique histogram2d y vals --- src/traces/histogram2d/calc.js | 4 ++-- test/jasmine/tests/hover_label_test.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/traces/histogram2d/calc.js b/src/traces/histogram2d/calc.js index c1d08ae2f27..480140442e2 100644 --- a/src/traces/histogram2d/calc.js +++ b/src/traces/histogram2d/calc.js @@ -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]); diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js index 6b3e6192684..068ff1c11b6 100644 --- a/test/jasmine/tests/hover_label_test.js +++ b/test/jasmine/tests/hover_label_test.js @@ -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();