@@ -650,26 +650,12 @@ function _hover(gd, evt, subplot, noHoverEvent) {
650
650
hoverData [ 0 ] . trace . type !== 'splom' // TODO: add support for splom
651
651
) {
652
652
var winningPoint = hoverData [ 0 ] ;
653
- var cd0 = winningPoint . cd [ winningPoint . index ] ;
654
653
var isGrouped = ( fullLayout . boxmode === 'group' || fullLayout . violinmode === 'group' ) ;
655
654
656
- var xVal = winningPoint . xVal ;
657
- var ax = winningPoint . xa ;
658
- if ( ax . type === 'category' ) xVal = ax . _categoriesMap [ xVal ] ;
659
- if ( ax . type === 'date' ) xVal = ax . d2c ( xVal ) ;
660
- if ( cd0 && cd0 . t && cd0 . t . posLetter === ax . _id && isGrouped ) {
661
- xVal += cd0 . t . dPos ;
662
- }
663
-
664
- var yVal = winningPoint . yVal ;
665
- ax = winningPoint . ya ;
666
- if ( ax . type === 'category' ) yVal = ax . _categoriesMap [ yVal ] ;
667
- if ( ax . type === 'date' ) yVal = ax . d2c ( yVal ) ;
668
- if ( cd0 && cd0 . t && cd0 . t . posLetter === ax . _id && isGrouped ) {
669
- yVal += cd0 . t . dPos ;
670
- }
671
-
672
- findHoverPoints ( xVal , yVal ) ;
655
+ findHoverPoints (
656
+ getVal ( 'x' , winningPoint , isGrouped ) ,
657
+ getVal ( 'y' , winningPoint , isGrouped )
658
+ ) ;
673
659
674
660
// Remove duplicated hoverData points
675
661
// note that d3 also filters identical points in the rendering steps
@@ -1911,3 +1897,17 @@ function orderPeriod(hoverData, hovermode) {
1911
1897
1912
1898
hoverData = first . concat ( last ) ;
1913
1899
}
1900
+
1901
+ function getVal ( axLetter , winningPoint , isGrouped ) {
1902
+ var cd0 = winningPoint . cd [ winningPoint . index ] ;
1903
+ var ax = winningPoint [ axLetter + 'a' ] ;
1904
+ var val = winningPoint [ axLetter + 'Val' ] ;
1905
+
1906
+ if ( ax . type === 'category' ) val = ax . _categoriesMap [ val ] ;
1907
+ if ( ax . type === 'date' ) val = ax . d2c ( val ) ;
1908
+ if ( cd0 && cd0 . t && cd0 . t . posLetter === ax . _id && isGrouped ) {
1909
+ val += cd0 . t . dPos ;
1910
+ }
1911
+
1912
+ return val ;
1913
+ }
0 commit comments