From f22c3d9df21f93a5df92c3f9b8c9bcbed6f0b408 Mon Sep 17 00:00:00 2001 From: Ya-Fan Chen <20377719+Lexachoc@users.noreply.github.com> Date: Thu, 31 Jul 2025 18:11:10 +0200 Subject: [PATCH 1/7] fix hover event issue for histogram --- src/components/fx/hover.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/fx/hover.js b/src/components/fx/hover.js index 7917ce3a1e8..c7614ad85d5 100644 --- a/src/components/fx/hover.js +++ b/src/components/fx/hover.js @@ -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; } From 314e29da6f4dd6296615e4ad90a1ac06a3f9e978 Mon Sep 17 00:00:00 2001 From: Ya-Fan Chen <20377719+Lexachoc@users.noreply.github.com> Date: Thu, 31 Jul 2025 18:19:24 +0200 Subject: [PATCH 2/7] Create 7503_fix.md --- draftlogs/7503_fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/7503_fix.md diff --git a/draftlogs/7503_fix.md b/draftlogs/7503_fix.md new file mode 100644 index 00000000000..745966c4b71 --- /dev/null +++ b/draftlogs/7503_fix.md @@ -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)] From 280600d90d5bebdfda01c9cce3abdf423b54b17d Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Fri, 1 Aug 2025 15:35:20 -0600 Subject: [PATCH 3/7] Add test for bin number change --- test/jasmine/tests/hover_label_test.js | 37 +++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js index 12316d30eb0..ba3211c458a 100644 --- a/test/jasmine/tests/hover_label_test.js +++ b/test/jasmine/tests/hover_label_test.js @@ -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(); @@ -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) { From 5afcdd436b3338edb435ec4a77ed329c613ca6d2 Mon Sep 17 00:00:00 2001 From: Ya-Fan Chen <20377719+Lexachoc@users.noreply.github.com> Date: Sat, 2 Aug 2025 01:09:52 +0200 Subject: [PATCH 4/7] Update src/components/fx/hover.js no need to coerce binNumber from integer to string as suggested Co-authored-by: Cameron DeCoster --- src/components/fx/hover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/fx/hover.js b/src/components/fx/hover.js index c7614ad85d5..41ee1352f62 100644 --- a/src/components/fx/hover.js +++ b/src/components/fx/hover.js @@ -2284,7 +2284,7 @@ function hoverChanged(gd, evt, oldhoverdata) { if(oldPt.curveNumber !== newPt.curveNumber || String(oldPt.pointNumber) !== String(newPt.pointNumber) || String(oldPt.pointNumbers) !== String(newPt.pointNumbers) || - String(oldPt.binNumber) !== String(newPt.binNumber) + oldPt.binNumber !== newPt.binNumber ) { return true; } From 9c92a2b3c8fb1ae5583b62ee2eb25d1ea3a635bb Mon Sep 17 00:00:00 2001 From: Ya-Fan Chen <20377719+Lexachoc@users.noreply.github.com> Date: Sun, 3 Aug 2025 03:18:03 +0200 Subject: [PATCH 5/7] Update 7503_fix.md --- draftlogs/7503_fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draftlogs/7503_fix.md b/draftlogs/7503_fix.md index 745966c4b71..bb163878f13 100644 --- a/draftlogs/7503_fix.md +++ b/draftlogs/7503_fix.md @@ -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)] +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)] From 80606da1210a2e18e5699af15969125ef9bc8b96 Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Mon, 4 Aug 2025 09:46:09 -0600 Subject: [PATCH 6/7] Update 7503_fix.md --- draftlogs/7503_fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draftlogs/7503_fix.md b/draftlogs/7503_fix.md index bb163878f13..cd0cbdc872b 100644 --- a/draftlogs/7503_fix.md +++ b/draftlogs/7503_fix.md @@ -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)] +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 @Lexahoc for the contribution! From 7f765e4e53fbea4d13c9cad0253603db2a092209 Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Mon, 4 Aug 2025 09:47:43 -0600 Subject: [PATCH 7/7] Fix typo in 7503_fix.md --- draftlogs/7503_fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draftlogs/7503_fix.md b/draftlogs/7503_fix.md index cd0cbdc872b..b7f5d40bb50 100644 --- a/draftlogs/7503_fix.md +++ b/draftlogs/7503_fix.md @@ -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 @Lexahoc for the contribution! +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!