@@ -2378,6 +2378,168 @@ describe('hover info on stacked subplots', function() {
23782378 } ) ;
23792379} ) ;
23802380
2381+ describe ( 'hover on subplots when hoversameaxis is set to true and x hovermode' , function ( ) {
2382+ 'use strict' ;
2383+
2384+ var mock = {
2385+ layout : {
2386+ hoversameaxis : true ,
2387+ hovermode : 'x' ,
2388+ grid : {
2389+ rows : 3 ,
2390+ columns : 2 ,
2391+ pattern : 'coupled'
2392+ }
2393+ } ,
2394+
2395+ data : [
2396+ {
2397+ y : [ 1 , 2 , 3 ]
2398+ } ,
2399+ {
2400+ y : [ 10 , 20 , 30 ] ,
2401+ yaxis : 'y2'
2402+ } ,
2403+ {
2404+ y : [ 100 , 200 , 300 ] ,
2405+ yaxis : 'y3'
2406+ } ,
2407+ {
2408+ y : [ 10 , 20 , 30 ] ,
2409+ xaxis : 'x2' ,
2410+ yaxis : 'y2'
2411+ }
2412+ ] ,
2413+ } ;
2414+
2415+ var gd ;
2416+
2417+ beforeEach ( function ( done ) {
2418+ gd = createGraphDiv ( ) ;
2419+ Plotly . newPlot ( gd , mock ) . then ( done ) ;
2420+ } ) ;
2421+
2422+ afterEach ( destroyGraphDiv ) ;
2423+
2424+ it ( 'hovermode: x with hoversameaxis: true' , function ( ) {
2425+ var pos = 0 ;
2426+ var subplot = 'xy' ;
2427+ Lib . clearThrottle ( ) ;
2428+ Plotly . Fx . hover ( gd , { xval : pos } , subplot ) ;
2429+ expect ( gd . _hoverdata . length ) . toBe ( 3 ) ;
2430+ assertHoverLabelContent ( {
2431+ nums : [ '1' , '10' , '100' ] ,
2432+ name : [ 'trace 0' , 'trace 1' , 'trace 2' ] ,
2433+ axis : String ( [ pos ] )
2434+ } ) ;
2435+
2436+ pos = 1 ;
2437+ subplot = 'xy2' ;
2438+ Lib . clearThrottle ( ) ;
2439+ Plotly . Fx . hover ( gd , { xval : pos } , subplot ) ;
2440+
2441+ expect ( gd . _hoverdata . length ) . toBe ( 3 ) ;
2442+ assertHoverLabelContent ( {
2443+ nums : [ '2' , '20' , '200' ] ,
2444+ name : [ 'trace 0' , 'trace 1' , 'trace 2' ] ,
2445+ axis : String ( pos )
2446+ } ) ;
2447+
2448+ pos = 2 ;
2449+ subplot = 'xy3' ;
2450+ Lib . clearThrottle ( ) ;
2451+ Plotly . Fx . hover ( gd , { xval : pos } , subplot ) ;
2452+
2453+ expect ( gd . _hoverdata . length ) . toBe ( 3 ) ;
2454+ assertHoverLabelContent ( {
2455+ nums : [ '3' , '30' , '300' ] ,
2456+ name : [ 'trace 0' , 'trace 1' , 'trace 2' ] ,
2457+ axis : String ( pos )
2458+ } ) ;
2459+ } ) ;
2460+ } ) ;
2461+
2462+ describe ( 'hover on subplots when hoversameaxis is set to true and y hovermode' , function ( ) {
2463+ 'use strict' ;
2464+
2465+ var mock = {
2466+ layout : {
2467+ hoversameaxis : true ,
2468+ hovermode : 'y' ,
2469+ grid : {
2470+ rows : 2 ,
2471+ columns : 3 ,
2472+ pattern : 'coupled'
2473+ }
2474+ } ,
2475+
2476+ data : [
2477+ {
2478+ x : [ 1 , 2 , 3 ]
2479+ } ,
2480+ {
2481+ x : [ 10 , 20 , 30 ] ,
2482+ xaxis : 'x2'
2483+ } ,
2484+ {
2485+ x : [ 100 , 200 , 300 ] ,
2486+ xaxis : 'x3'
2487+ } ,
2488+ {
2489+ x : [ 10 , 20 , 30 ] ,
2490+ xaxis : 'x2' ,
2491+ yaxis : 'y2'
2492+ }
2493+ ] ,
2494+ } ;
2495+
2496+ var gd ;
2497+
2498+ beforeEach ( function ( done ) {
2499+ gd = createGraphDiv ( ) ;
2500+ Plotly . newPlot ( gd , mock ) . then ( done ) ;
2501+ } ) ;
2502+
2503+ afterEach ( destroyGraphDiv ) ;
2504+
2505+ it ( 'hovermode: y with hoversameaxis: true' , function ( ) {
2506+ var pos = 0 ;
2507+ var subplot = 'xy' ;
2508+ Lib . clearThrottle ( ) ;
2509+ Plotly . Fx . hover ( gd , { yval : pos } , subplot ) ;
2510+ expect ( gd . _hoverdata . length ) . toBe ( 3 ) ;
2511+ assertHoverLabelContent ( {
2512+ nums : [ '1' , '10' , '100' ] ,
2513+ name : [ 'trace 0' , 'trace 1' , 'trace 2' ] ,
2514+ axis : String ( [ pos ] )
2515+ } ) ;
2516+
2517+ pos = 1 ;
2518+ subplot = 'x2y' ;
2519+ Lib . clearThrottle ( ) ;
2520+ Plotly . Fx . hover ( gd , { yval : pos } , subplot ) ;
2521+
2522+ expect ( gd . _hoverdata . length ) . toBe ( 3 ) ;
2523+ assertHoverLabelContent ( {
2524+ nums : [ '2' , '20' , '200' ] ,
2525+ name : [ 'trace 0' , 'trace 1' , 'trace 2' ] ,
2526+ axis : String ( pos )
2527+ } ) ;
2528+
2529+ pos = 2 ;
2530+ subplot = 'x3y' ;
2531+ Lib . clearThrottle ( ) ;
2532+ Plotly . Fx . hover ( gd , { yval : pos } , subplot ) ;
2533+
2534+ expect ( gd . _hoverdata . length ) . toBe ( 3 ) ;
2535+ assertHoverLabelContent ( {
2536+ nums : [ '3' , '30' , '300' ] ,
2537+ name : [ 'trace 0' , 'trace 1' , 'trace 2' ] ,
2538+ axis : String ( pos )
2539+ } ) ;
2540+ } ) ;
2541+ } ) ;
2542+
23812543describe ( 'hover on many lines+bars' , function ( ) {
23822544 'use strict' ;
23832545
0 commit comments