Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bddbb14

Browse files
Merge pull request #7503 from Lexachoc/fix-hover-histogram
fix hover event not triggered on consecutive empty bins (count=0) with `hovermode:'x'` for histogram
2 parents 1d5a249 + 7f765e4 commit bddbb14

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

‎draftlogs/7503_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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)], with thanks to @Lexachoc for the contribution!

‎src/components/fx/hover.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,8 @@ function hoverChanged(gd, evt, oldhoverdata) {
22832283

22842284
if(oldPt.curveNumber !== newPt.curveNumber ||
22852285
String(oldPt.pointNumber) !== String(newPt.pointNumber) ||
2286-
String(oldPt.pointNumbers) !== String(newPt.pointNumbers)
2286+
String(oldPt.pointNumbers) !== String(newPt.pointNumbers) ||
2287+
oldPt.binNumber !== newPt.binNumber
22872288
) {
22882289
return true;
22892290
}

‎test/jasmine/tests/hover_label_test.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ describe('hover info', function() {
11881188
});
11891189
})
11901190
.then(done, done.fail);
1191-
});
1191+
});
11921192

11931193
it('will show a category range if you ask nicely', function(done) {
11941194
var gd = createGraphDiv();
@@ -1217,6 +1217,41 @@ describe('hover info', function() {
12171217
})
12181218
.then(done, done.fail);
12191219
});
1220+
1221+
it('will update when switching from one empty bin to another', done => {
1222+
const gd = createGraphDiv();
1223+
1224+
Plotly
1225+
.newPlot(
1226+
gd,
1227+
[{
1228+
x: [
1229+
0.025,0.025,0.025,0.025,0.025,
1230+
0.075,0.075,0.075,0.075,0.075,
1231+
0.125,0.125,0.125,0.125,0.125,0.125,
1232+
0.175,0.175,0.175,0.175,
1233+
0.475,0.475,0.475
1234+
],
1235+
xbins: { start: 0, end: 0.5, size: 0.10 },
1236+
type: 'histogram'
1237+
}],
1238+
{
1239+
hovermode: 'x',
1240+
width: 500,
1241+
height: 400,
1242+
margin: {l: 0, t: 0, r: 0, b: 0}
1243+
}
1244+
)
1245+
.then(() => {
1246+
let hoverData;
1247+
gd.on('plotly_hover', e => { hoverData = e; });
1248+
_hoverNatural(gd, 250, 200);
1249+
expect(hoverData.points[0].binNumber).toBe(2)
1250+
_hoverNatural(gd, 300, 200);
1251+
expect(hoverData.points[0].binNumber).toBe(3)
1252+
})
1253+
.then(done, done.fail);
1254+
});
12201255
});
12211256

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /