@@ -2698,8 +2698,8 @@ describe('Hover on axes with rangebreaks', function() {
26982698 mouseEvent ( 'mousemove' , x , y ) ;
26992699 }
27002700
2701- function _assert ( msg , exp ) {
2702- assertHoverLabelContent ( { nums : exp . nums , axis : exp . axis } , msg + '| hover label' ) ;
2701+ function _assert ( msg , exp , noHoverLabel ) {
2702+ if ( ! noHoverLabel ) assertHoverLabelContent ( { nums : exp . nums , axis : exp . axis } , msg + '| hover label' ) ;
27032703 expect ( eventData . x ) . toBe ( exp . x , 'event data x' ) ;
27042704 expect ( eventData . y ) . toBe ( exp . y , 'event data y' ) ;
27052705 }
@@ -2772,6 +2772,85 @@ describe('Hover on axes with rangebreaks', function() {
27722772 . then ( done ) ;
27732773 } ) ;
27742774
2775+ it ( 'should work when rangebreaks are present on y-axis using hovermode x (case of bar and autorange reversed)' , function ( done ) {
2776+ Plotly . plot ( gd , [ {
2777+ type : 'bar' ,
2778+ orientation : 'h' ,
2779+ y : [
2780+ '1970-01-01 00:00:00.000' ,
2781+ '1970-01-01 00:00:00.010' ,
2782+ '1970-01-01 00:00:00.050' ,
2783+ '1970-01-01 00:00:00.090' ,
2784+ '1970-01-01 00:00:00.095' ,
2785+ '1970-01-01 00:00:00.100' ,
2786+ '1970-01-01 00:00:00.150' ,
2787+ '1970-01-01 00:00:00.190' ,
2788+ '1970-01-01 00:00:00.200'
2789+ ] ,
2790+ x : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ]
2791+ } ] , {
2792+ yaxis : {
2793+ autorange : 'reversed' ,
2794+ rangebreaks : [
2795+ { bounds : [
2796+ '1970-01-01 00:00:00.011' ,
2797+ '1970-01-01 00:00:00.089'
2798+ ] } ,
2799+ { bounds : [
2800+ '1970-01-01 00:00:00.101' ,
2801+ '1970-01-01 00:00:00.189'
2802+ ] }
2803+ ]
2804+ } ,
2805+ width : 400 ,
2806+ height : 400 ,
2807+ margin : { l : 10 , t : 10 , b : 10 , r : 10 } ,
2808+ hovermode : 'x'
2809+ } )
2810+ . then ( function ( ) {
2811+ gd . on ( 'plotly_hover' , function ( d ) {
2812+ eventData = d . points [ 0 ] ;
2813+ } ) ;
2814+ } )
2815+ . then ( function ( ) { _hover ( 50 , 350 ) ; } )
2816+ . then ( function ( ) {
2817+ _assert ( '1st test' , {
2818+ axis : '1' ,
2819+ nums : 'Jan 1, 1970, 00:00:00.01' ,
2820+ y : '1970-01-01 00:00:00.01' ,
2821+ x : 1
2822+ } ) ;
2823+ } )
2824+ . then ( function ( ) { _hover ( 200 , 200 ) ; } )
2825+ . then ( function ( ) {
2826+ _assert ( '2nd test' , {
2827+ axis : '5' ,
2828+ nums : 'Jan 1, 1970, 00:00:00.1' ,
2829+ y : '1970-01-01 00:00:00.1' ,
2830+ x : 5
2831+ } ) ;
2832+ } )
2833+ . then ( function ( ) { _hover ( 250 , 150 ) ; } ) // hover over break
2834+ . then ( function ( ) {
2835+ _assert ( '3rd test' , {
2836+ // previous values
2837+ y : '1970-01-01 00:00:00.1' ,
2838+ x : 5
2839+ } , 'noHoverLabel' ) ;
2840+ } )
2841+ . then ( function ( ) { _hover ( 350 , 50 ) ; } )
2842+ . then ( function ( ) {
2843+ _assert ( '4th test' , {
2844+ axis : '8' ,
2845+ nums : 'Jan 1, 1970, 00:00:00.2' ,
2846+ y : '1970-01-01 00:00:00.2' ,
2847+ x : 8
2848+ } ) ;
2849+ } )
2850+ . catch ( failTest )
2851+ . then ( done ) ;
2852+ } ) ;
2853+
27752854 it ( 'should work when rangebreaks are present on y-axis' , function ( done ) {
27762855 Plotly . plot ( gd , [ {
27772856 mode : 'lines' , // i.e. no autorange padding
0 commit comments