Skip to content

Commit

Permalink
Merge pull request #4537 from plotly/waterfall-closest-below-value-axis
Browse files Browse the repository at this point in the history
Fix waterfall 'closest' hover when cursor is below the size axis
  • Loading branch information
etpinard authored Jan 31, 2020
2 parents 4052a03 + ff71362 commit 71e87e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/traces/bar/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
var s = di[sizeLetter];

if(isWaterfall) {
s += Math.abs(di.rawS || 0);
var rawS = Math.abs(di.rawS) || 0;
if(v > 0) {
s += rawS;
} else if(v < 0) {
s -= rawS;
}
}

// add a gradient so hovering near the end of a
Expand Down
1 change: 1 addition & 0 deletions test/image/compare_pixels_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ if(allMock || argv.filter) {
}

var FLAKY_LIST = [
'treemap_coffee',
'treemap_textposition',
'treemap_with-without_values',
'trace_metatext',
Expand Down
7 changes: 7 additions & 0 deletions test/jasmine/tests/waterfall_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,13 @@ describe('waterfall hover', function() {
expect(out.style).toBeCloseToArray([1, '#FF4136', 1, -9.47]);
assertPos(out.pos, [137, 181, 266, 266]);
});

it('should return the correct hover point data (case closest - decreasing case, below y=0)', function() {
var out = _hover(gd, 1.8, -5, 'closest');

expect(out.style).toBeCloseToArray([2, '#3D9970', 2, 16.59]);
assertPos(out.pos, [260, 304, 21, 21]);
});
});

describe('text labels', function() {
Expand Down

0 comments on commit 71e87e6

Please sign in to comment.