From 534f9db5bfc3031e209a97f2f70032b30bec3086 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Fri, 12 Apr 2024 17:59:40 -0400 Subject: [PATCH 1/2] avoid duplicates in splom hover --- src/traces/splom/hover.js | 3 +++ test/jasmine/tests/hover_label_test.js | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/traces/splom/hover.js b/src/traces/splom/hover.js index 56a532e07aa..d3b891542e2 100644 --- a/src/traces/splom/hover.js +++ b/src/traces/splom/hover.js @@ -27,6 +27,9 @@ function hoverPoints(pointData, xval, yval, hovermode, opts) { for(var i = 0; i < subplotsWith.length; i++) { var spId = subplotsWith[i]; + // do not reselect on the initial subplot + if(spId === (pointData.xa._id + pointData.ya._id)) continue; + if(hovermodeHasY) { _pointData.xa = getFromId(gd, spId, 'x'); } else { // hovermodeHasX diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js index e666526651e..a45b1571fe2 100644 --- a/test/jasmine/tests/hover_label_test.js +++ b/test/jasmine/tests/hover_label_test.js @@ -2640,7 +2640,7 @@ describe('splom hover on subplots when hoversubplots is set to *axis* and (x|y) it('splom hoversubplots: *axis*', function() { Lib.clearThrottle(); Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy'); - expect(gd._hoverdata.length).toBe(3); + expect(gd._hoverdata.length).toBe(2); assertHoverLabelContent({ nums: ['100', '100k'], name: ['', ''], @@ -2651,12 +2651,12 @@ describe('splom hover on subplots when hoversubplots is set to *axis* and (x|y) Lib.clearThrottle(); Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy'); - expect(gd._hoverdata.length).toBe(3); + expect(gd._hoverdata.length).toBe(2); Plotly.relayout(gd, 'hovermode', 'y unified'); Lib.clearThrottle(); Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy'); - expect(gd._hoverdata.length).toBe(3); + expect(gd._hoverdata.length).toBe(2); }); }); @@ -2696,7 +2696,7 @@ describe('splom hover *axis* hoversubplots splom points on same position should it('splom *axis* hoversubplots', function() { Lib.clearThrottle(); Plotly.Fx.hover(gd, {}, 'xy'); - expect(gd._hoverdata.length).toBe(5); + expect(gd._hoverdata.length).toBe(4); assertHoverLabelContent({ nums: ['1', '1', '1', '1'], name: ['', '', '', ''], @@ -2705,7 +2705,7 @@ describe('splom hover *axis* hoversubplots splom points on same position should Lib.clearThrottle(); Plotly.Fx.hover(gd, {}, 'xy2'); - expect(gd._hoverdata.length).toBe(4); + expect(gd._hoverdata.length).toBe(3); assertHoverLabelContent({ nums: ['1', '2', '2'], name: ['', '', ''], @@ -2714,7 +2714,7 @@ describe('splom hover *axis* hoversubplots splom points on same position should Lib.clearThrottle(); Plotly.Fx.hover(gd, {}, 'xy3'); - expect(gd._hoverdata.length).toBe(4); + expect(gd._hoverdata.length).toBe(3); assertHoverLabelContent({ nums: ['1', '2', '2'], name: ['', '', ''], @@ -2723,7 +2723,7 @@ describe('splom hover *axis* hoversubplots splom points on same position should Lib.clearThrottle(); Plotly.Fx.hover(gd, {}, 'xy4'); - expect(gd._hoverdata.length).toBe(5); + expect(gd._hoverdata.length).toBe(4); assertHoverLabelContent({ nums: ['1', '3', '3', '3'], name: ['', '', '', ''], @@ -2732,7 +2732,7 @@ describe('splom hover *axis* hoversubplots splom points on same position should Lib.clearThrottle(); Plotly.Fx.hover(gd, {}, 'x2y'); - expect(gd._hoverdata.length).toBe(5); + expect(gd._hoverdata.length).toBe(4); assertHoverLabelContent({ nums: ['1', '3', '3', '3'], name: ['', '', '', ''], @@ -2741,7 +2741,7 @@ describe('splom hover *axis* hoversubplots splom points on same position should Lib.clearThrottle(); Plotly.Fx.hover(gd, {}, 'x3y'); - expect(gd._hoverdata.length).toBe(5); + expect(gd._hoverdata.length).toBe(4); assertHoverLabelContent({ nums: ['1', '3', '3', '3'], name: ['', '', '', ''], @@ -2750,7 +2750,7 @@ describe('splom hover *axis* hoversubplots splom points on same position should Lib.clearThrottle(); Plotly.Fx.hover(gd, {}, 'x4y'); - expect(gd._hoverdata.length).toBe(5); + expect(gd._hoverdata.length).toBe(4); assertHoverLabelContent({ nums: ['1', '3', '3', '3'], name: ['', '', '', ''], From 996593ad23c4c5607bc7e60237b715ca277be817 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Fri, 12 Apr 2024 18:21:54 -0400 Subject: [PATCH 2/2] draftlog --- draftlogs/6965_fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/6965_fix.md diff --git a/draftlogs/6965_fix.md b/draftlogs/6965_fix.md new file mode 100644 index 00000000000..562350897d1 --- /dev/null +++ b/draftlogs/6965_fix.md @@ -0,0 +1 @@ + - Fix duplicated points in splom hover when `hoversubplots` is set to "axis" [[#6965](https://github.com/plotly/plotly.js/pull/6965)]