Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb704dc

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix6960-hoversubplots
- resolved conflicts in test/jasmine/tests/hover_label_test.js
2 parents 337cda0 + f673ce6 commit bb704dc

File tree

3 files changed

+14
-31
lines changed

3 files changed

+14
-31
lines changed

draftlogs/6965_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix duplicated points in splom hover when `hoversubplots` is set to "axis" [[#6965](https://github.com/plotly/plotly.js/pull/6965)]

src/traces/splom/hover.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ function hoverPoints(pointData, xval, yval, hovermode, opts) {
2727
for(var i = 0; i < subplotsWith.length; i++) {
2828
var spId = subplotsWith[i];
2929

30+
// do not reselect on the initial subplot
31+
if(spId === (pointData.xa._id + pointData.ya._id)) continue;
32+
3033
if(hovermodeHasY) {
3134
_pointData.xa = getFromId(gd, spId, 'x');
3235
} else { // hovermodeHasX

test/jasmine/tests/hover_label_test.js

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,32 +2666,25 @@ describe('splom hover on subplots when hoversubplots is set to *axis* and (x|y)
26662666
it('splom hoversubplots: *axis*', function() {
26672667
Lib.clearThrottle();
26682668
Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy');
2669-
expect(gd._hoverdata.length).toBe(3);
2670-
26712669
assertFirstPointOn(gd, 'x', 'y');
2672-
2670+
expect(gd._hoverdata.length).toBe(2);
26732671
assertHoverLabelContent({
26742672
nums: ['100', '100k'],
26752673
name: ['', ''],
26762674
axis: '100'
26772675
});
26782676

26792677
Plotly.relayout(gd, 'hovermode', 'x unified');
2680-
26812678
Lib.clearThrottle();
26822679
Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy');
2683-
26842680
assertFirstPointOn(gd, 'x', 'y');
2685-
2686-
expect(gd._hoverdata.length).toBe(3);
2681+
expect(gd._hoverdata.length).toBe(2);
26872682

26882683
Plotly.relayout(gd, 'hovermode', 'y unified');
26892684
Lib.clearThrottle();
26902685
Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy');
2691-
26922686
assertFirstPointOn(gd, 'x', 'y');
2693-
2694-
expect(gd._hoverdata.length).toBe(3);
2687+
expect(gd._hoverdata.length).toBe(2);
26952688
});
26962689
});
26972690

@@ -2731,10 +2724,8 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27312724
it('splom *axis* hoversubplots', function() {
27322725
Lib.clearThrottle();
27332726
Plotly.Fx.hover(gd, {}, 'xy');
2734-
expect(gd._hoverdata.length).toBe(5);
2735-
27362727
assertFirstPointOn(gd, 'x', 'y');
2737-
2728+
expect(gd._hoverdata.length).toBe(4);
27382729
assertHoverLabelContent({
27392730
nums: ['1', '1', '1', '1'],
27402731
name: ['', '', '', ''],
@@ -2743,10 +2734,8 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27432734

27442735
Lib.clearThrottle();
27452736
Plotly.Fx.hover(gd, {}, 'xy2');
2746-
expect(gd._hoverdata.length).toBe(4);
2747-
27482737
assertFirstPointOn(gd, 'x', 'y2');
2749-
2738+
expect(gd._hoverdata.length).toBe(3);
27502739
assertHoverLabelContent({
27512740
nums: ['1', '2', '2'],
27522741
name: ['', '', ''],
@@ -2755,10 +2744,8 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27552744

27562745
Lib.clearThrottle();
27572746
Plotly.Fx.hover(gd, {}, 'xy3');
2758-
expect(gd._hoverdata.length).toBe(4);
2759-
27602747
assertFirstPointOn(gd, 'x', 'y3');
2761-
2748+
expect(gd._hoverdata.length).toBe(3);
27622749
assertHoverLabelContent({
27632750
nums: ['1', '2', '2'],
27642751
name: ['', '', ''],
@@ -2767,10 +2754,8 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27672754

27682755
Lib.clearThrottle();
27692756
Plotly.Fx.hover(gd, {}, 'xy4');
2770-
expect(gd._hoverdata.length).toBe(5);
2771-
27722757
assertFirstPointOn(gd, 'x', 'y4');
2773-
2758+
expect(gd._hoverdata.length).toBe(4);
27742759
assertHoverLabelContent({
27752760
nums: ['1', '3', '3', '3'],
27762761
name: ['', '', '', ''],
@@ -2779,10 +2764,8 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27792764

27802765
Lib.clearThrottle();
27812766
Plotly.Fx.hover(gd, {}, 'x2y');
2782-
expect(gd._hoverdata.length).toBe(5);
2783-
27842767
assertFirstPointOn(gd, 'x2', 'y');
2785-
2768+
expect(gd._hoverdata.length).toBe(4);
27862769
assertHoverLabelContent({
27872770
nums: ['1', '3', '3', '3'],
27882771
name: ['', '', '', ''],
@@ -2791,10 +2774,8 @@ describe('splom hover *axis* hoversubplots splom points on same position should
27912774

27922775
Lib.clearThrottle();
27932776
Plotly.Fx.hover(gd, {}, 'x3y');
2794-
expect(gd._hoverdata.length).toBe(5);
2795-
27962777
assertFirstPointOn(gd, 'x3', 'y');
2797-
2778+
expect(gd._hoverdata.length).toBe(4);
27982779
assertHoverLabelContent({
27992780
nums: ['1', '3', '3', '3'],
28002781
name: ['', '', '', ''],
@@ -2803,10 +2784,8 @@ describe('splom hover *axis* hoversubplots splom points on same position should
28032784

28042785
Lib.clearThrottle();
28052786
Plotly.Fx.hover(gd, {}, 'x4y');
2806-
expect(gd._hoverdata.length).toBe(5);
2807-
28082787
assertFirstPointOn(gd, 'x4', 'y');
2809-
2788+
expect(gd._hoverdata.length).toBe(4);
28102789
assertHoverLabelContent({
28112790
nums: ['1', '3', '3', '3'],
28122791
name: ['', '', '', ''],

0 commit comments

Comments
 (0)