@@ -777,6 +777,42 @@ describe('sankey tests', function() {
777
777
. then ( done ) ;
778
778
} ) ;
779
779
780
+ it ( 'should position hover labels correctly' , function ( done ) {
781
+ var gd = createGraphDiv ( ) ;
782
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
783
+
784
+ Plotly . plot ( gd , mockCopy )
785
+ . then ( function ( ) {
786
+ _hover ( 900 , 230 ) ;
787
+
788
+ assertLabel (
789
+ [ 'source: Thermal generation' , 'target: Losses' , '787TWh' ] ,
790
+ [ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
791
+ ) ;
792
+
793
+ var g = d3 . select ( '.hovertext' ) ;
794
+ var pos = g . node ( ) . getBoundingClientRect ( ) ;
795
+ expect ( pos . x ) . toBeCloseTo ( 555 , - 1.5 , 'it should have correct x position' ) ;
796
+ expect ( pos . y ) . toBeCloseTo ( 196 , - 1.5 , 'it should have correct y position' ) ;
797
+ return Plotly . restyle ( gd , 'orientation' , 'v' ) ;
798
+ } )
799
+ . then ( function ( ) {
800
+ _hover ( 520 , 500 ) ;
801
+
802
+ assertLabel (
803
+ [ 'source: Thermal generation' , 'target: Losses' , '787TWh' ] ,
804
+ [ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
805
+ ) ;
806
+
807
+ var g = d3 . select ( '.hovertext' ) ;
808
+ var pos = g . node ( ) . getBoundingClientRect ( ) ;
809
+ expect ( pos . x ) . toBeCloseTo ( 279 , - 1.5 , 'it should have correct x position' ) ;
810
+ expect ( pos . y ) . toBeCloseTo ( 500 , - 1.5 , 'it should have correct y position' ) ;
811
+ } )
812
+ . catch ( failTest )
813
+ . then ( done ) ;
814
+ } ) ;
815
+
780
816
it ( 'should show the correct hover labels when hovertemplate is specified' , function ( done ) {
781
817
var gd = createGraphDiv ( ) ;
782
818
var mockCopy = Lib . extendDeep ( { } , mock ) ;
0 commit comments