@@ -1668,6 +1668,10 @@ describe('hover info', function() {
1668
1668
return Math . max ( 0 , overlap ) ;
1669
1669
}
1670
1670
1671
+ function labelCount ( ) {
1672
+ return d3Select ( gd ) . selectAll ( 'g.hovertext' ) . size ( ) ;
1673
+ }
1674
+
1671
1675
it ( 'centered-aligned, should render labels inside boxes' , function ( done ) {
1672
1676
var trace1 = {
1673
1677
x : [ 'giraffes' ] ,
@@ -1787,6 +1791,59 @@ describe('hover info', function() {
1787
1791
} )
1788
1792
. then ( done , done . fail ) ;
1789
1793
} ) ;
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
+ var i ;
1809
+ for ( i = 0 ; i < 3 ; i ++ ) {
1810
+ data . push ( trace ( barName + i , 'bar' , 0.0 ) ) ;
1811
+ data . push ( trace ( scatterName + i , 'scatter' , 0.1 ) ) ;
1812
+ }
1813
+ var layout = {
1814
+ width : 600 ,
1815
+ height : 400 ,
1816
+ hovermode : 'x' ,
1817
+ } ;
1818
+
1819
+ Plotly . newPlot ( gd , data , layout )
1820
+ . then ( function ( ) {
1821
+ _hoverNatural ( gd , 200 , 200 ) ;
1822
+ } )
1823
+ . then ( function ( ) {
1824
+ expect ( labelCount ( ) ) . toBe ( 6 ) ;
1825
+ } )
1826
+ . then ( function ( ) {
1827
+ var nodes = [ ] ;
1828
+ for ( 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 ( 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
+ } ) ;
1790
1847
} ) ;
1791
1848
1792
1849
describe ( 'constraints info graph viewport' , function ( ) {
0 commit comments