@@ -3666,8 +3666,8 @@ describe('hovermode: (x|y)unified', function() {
3666
3666
Lib . clearThrottle ( ) ;
3667
3667
}
3668
3668
3669
- function assertElementCount ( className , size ) {
3670
- var g = d3 . selectAll ( 'g.' + className ) ;
3669
+ function assertElementCount ( selector , size ) {
3670
+ var g = d3 . selectAll ( selector ) ;
3671
3671
expect ( g . size ( ) ) . toBe ( size ) ;
3672
3672
}
3673
3673
@@ -3788,6 +3788,28 @@ describe('hovermode: (x|y)unified', function() {
3788
3788
. then ( done ) ;
3789
3789
} ) ;
3790
3790
3791
+ it ( 'shares filtering logic with compare mode x' , function ( done ) {
3792
+ var mock = require ( '@mocks/27.json' ) ;
3793
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
3794
+
3795
+ Plotly . newPlot ( gd , mockCopy )
3796
+ . then ( function ( gd ) {
3797
+ _hover ( gd , { xval : '2002' } ) ;
3798
+ assertElementCount ( 'g.hovertext' , 2 ) ;
3799
+
3800
+ return Plotly . relayout ( gd , 'hovermode' , 'x unified' ) ;
3801
+ } )
3802
+ . then ( function ( ) {
3803
+ _hover ( gd , { xval : '2002' } ) ;
3804
+ assertLabel ( { title : '2002.042' , items : [
3805
+ 'Market income : 0.5537845' ,
3806
+ 'Market incom... : 0.4420997'
3807
+ ] } ) ;
3808
+ } )
3809
+ . catch ( failTest )
3810
+ . then ( done ) ;
3811
+ } ) ;
3812
+
3791
3813
it ( 'should order items in the same way as the legend' , function ( done ) {
3792
3814
var mock = require ( '@mocks/stacked_area.json' ) ;
3793
3815
var mockCopy = Lib . extendDeep ( { } , mock ) ;
@@ -3826,6 +3848,21 @@ describe('hovermode: (x|y)unified', function() {
3826
3848
. then ( done ) ;
3827
3849
} ) ;
3828
3850
3851
+ it ( 'should work for "legend_horizontal_autowrap"' , function ( done ) {
3852
+ var mock = require ( '@mocks/legend_horizontal_autowrap.json' ) ;
3853
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
3854
+ mockCopy . layout . hovermode = 'x unified' ;
3855
+ Plotly . newPlot ( gd , mockCopy )
3856
+ . then ( function ( gd ) {
3857
+ _hover ( gd , { xval : 1 } ) ;
3858
+
3859
+ assertElementCount ( 'g.hoverlayer g.legend' , 1 ) ;
3860
+ assertElementCount ( 'g.hoverlayer g.traces' , 20 ) ;
3861
+ } )
3862
+ . catch ( failTest )
3863
+ . then ( done ) ;
3864
+ } ) ;
3865
+
3829
3866
it ( 'should style scatter symbols accordingly' , function ( done ) {
3830
3867
var mock = require ( '@mocks/marker_colorscale_template.json' ) ;
3831
3868
var mockCopy = Lib . extendDeep ( { } , mock ) ;
@@ -3934,16 +3971,16 @@ describe('hovermode: (x|y)unified', function() {
3934
3971
. then ( function ( gd ) {
3935
3972
_hover ( gd , { xval : 3 } ) ;
3936
3973
3937
- assertElementCount ( 'hovertext' , 2 ) ;
3938
- assertElementCount ( 'legend' , 0 ) ;
3974
+ assertElementCount ( 'g. hovertext' , 2 ) ;
3975
+ assertElementCount ( 'g. legend' , 0 ) ;
3939
3976
3940
3977
return Plotly . relayout ( gd , 'hovermode' , 'x unified' ) ;
3941
3978
} )
3942
3979
. then ( function ( gd ) {
3943
3980
_hover ( gd , { xval : 3 } ) ;
3944
3981
3945
- assertElementCount ( 'hovertext' , 0 ) ;
3946
- assertElementCount ( 'legend' , 1 ) ;
3982
+ assertElementCount ( 'g. hovertext' , 0 ) ;
3983
+ assertElementCount ( 'g. legend' , 1 ) ;
3947
3984
} )
3948
3985
. catch ( failTest )
3949
3986
. then ( done ) ;
0 commit comments