@@ -1668,6 +1668,10 @@ describe('hover info', function() {
16681668 return Math . max ( 0 , overlap ) ;
16691669 }
16701670
1671+ function labelCount ( ) {
1672+ return d3Select ( gd ) . selectAll ( 'g.hovertext' ) . size ( ) ;
1673+ }
1674+
16711675 it ( 'centered-aligned, should render labels inside boxes' , function ( done ) {
16721676 var trace1 = {
16731677 x : [ 'giraffes' ] ,
@@ -1787,6 +1791,59 @@ describe('hover info', function() {
17871791 } )
17881792 . then ( done , done . fail ) ;
17891793 } ) ;
1794+
1795+ it ( "does not overlap lebels for different trace types" , function ( done ) {
1796+ function trace ( name , type , delta ) {
1797+ return {
1798+ name : name ,
1799+ type : type ,
1800+ y : [ 0 + delta , 1 + delta , 2 + delta ] ,
1801+ x : [ "CAT 1" , "CAT 2" , "CAT 3" ] ,
1802+ } ;
1803+ }
1804+
1805+ var scatterName = "scatter_" ;
1806+ var barName = "bar_" ;
1807+ var data = [ ] ;
1808+ for ( let i = 0 ; i < 3 ; i ++ ) {
1809+ data . push ( trace ( barName + i , "bar" , 0.0 ) ) ;
1810+ data . push ( trace ( scatterName + i , "scatter" , 0.1 ) ) ;
1811+ }
1812+ var layout = {
1813+ width : 600 ,
1814+ height : 400 ,
1815+ hovermode : "x" ,
1816+ } ;
1817+
1818+ Plotly . newPlot ( gd , data , layout )
1819+ . then ( function ( ) {
1820+ _hoverNatural ( gd , 200 , 200 ) ;
1821+ } )
1822+ . then ( function ( ) {
1823+ expect ( labelCount ( ) ) . toBe ( 6 ) ;
1824+ } )
1825+ . then ( function ( ) {
1826+
1827+ var nodes = [ ] ;
1828+ for ( let i = 0 ; i < 3 ; i ++ ) {
1829+ nodes . push ( hoverInfoNodes ( barName + i ) . secondaryBox . getBoundingClientRect ( ) ) ;
1830+ nodes . push ( hoverInfoNodes ( scatterName + i ) . secondaryBox . getBoundingClientRect ( ) ) ;
1831+ }
1832+ nodes . sort ( function ( a , b ) { return a . top - b . top ; } ) ;
1833+
1834+ for ( let i = 0 ; i < 5 ; i ++ ) {
1835+ expect (
1836+ calcLineOverlap (
1837+ nodes [ i ] . top ,
1838+ nodes [ i ] . bottom ,
1839+ nodes [ i + 1 ] . top ,
1840+ nodes [ i + 1 ] . bottom ,
1841+ )
1842+ ) . toBeWithin ( 2 , 1 ) ;
1843+ }
1844+ } )
1845+ . then ( done , done . fail ) ;
1846+ } ) ;
17901847 } ) ;
17911848
17921849 describe ( 'constraints info graph viewport' , function ( ) {
0 commit comments