Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions draftlogs/7503_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix hover event not triggered on consecutive empty bins (count=0) with `hovermode:'x'` for histogram[[#7503](https://github.com/plotly/plotly.js/pull/7503)]
3 changes: 2 additions & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,8 @@ function hoverChanged(gd, evt, oldhoverdata) {

if(oldPt.curveNumber !== newPt.curveNumber ||
String(oldPt.pointNumber) !== String(newPt.pointNumber) ||
String(oldPt.pointNumbers) !== String(newPt.pointNumbers)
String(oldPt.pointNumbers) !== String(newPt.pointNumbers) ||
String(oldPt.binNumber) !== String(newPt.binNumber)
) {
return true;
}
Expand Down
37 changes: 36 additions & 1 deletion test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ describe('hover info', function() {
});
})
.then(done, done.fail);
});
});

it('will show a category range if you ask nicely', function(done) {
var gd = createGraphDiv();
Expand Down Expand Up @@ -1217,6 +1217,41 @@ describe('hover info', function() {
})
.then(done, done.fail);
});

it('will update when switching from one empty bin to another', done => {
const gd = createGraphDiv();

Plotly
.newPlot(
gd,
[{
x: [
0.025,0.025,0.025,0.025,0.025,
0.075,0.075,0.075,0.075,0.075,
0.125,0.125,0.125,0.125,0.125,0.125,
0.175,0.175,0.175,0.175,
0.475,0.475,0.475
],
xbins: { start: 0, end: 0.5, size: 0.10 },
type: 'histogram'
}],
{
hovermode: 'x',
width: 500,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0}
}
)
.then(() => {
let hoverData;
gd.on('plotly_hover', e => { hoverData = e; });
_hoverNatural(gd, 250, 200);
expect(hoverData.points[0].binNumber).toBe(2)
_hoverNatural(gd, 300, 200);
expect(hoverData.points[0].binNumber).toBe(3)
})
.then(done, done.fail);
});
});

['candlestick', 'ohlc'].forEach(function(type) {
Expand Down