@@ -665,6 +665,43 @@ describe('legend relayout update', function() {
665
665
. catch ( failTest )
666
666
. then ( done ) ;
667
667
} ) ;
668
+
669
+ describe ( 'should update legend valign' , function ( ) {
670
+ var mock = require ( '@mocks/legend_valign_top.json' ) ;
671
+ var gd ;
672
+
673
+ beforeEach ( function ( ) {
674
+ gd = createGraphDiv ( ) ;
675
+ } ) ;
676
+ afterEach ( destroyGraphDiv ) ;
677
+
678
+ function markerOffsetY ( ) {
679
+ var translateY = d3 . select ( '.legend .traces .layers' ) . attr ( 'transform' ) . match ( / t r a n s l a t e \( \d + , ( - ? \d + ) \) / ) [ 1 ] ;
680
+ return parseFloat ( translateY ) ;
681
+ }
682
+
683
+ it ( 'it should translate markers' , function ( done ) {
684
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
685
+
686
+ var top , middle , bottom ;
687
+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout )
688
+ . then ( function ( ) {
689
+ top = markerOffsetY ( ) ;
690
+ return Plotly . relayout ( gd , 'legend.valign' , 'middle' ) ;
691
+ } )
692
+ . then ( function ( ) {
693
+ middle = markerOffsetY ( ) ;
694
+ expect ( middle ) . toBeGreaterThan ( top ) ;
695
+ return Plotly . relayout ( gd , 'legend.valign' , 'bottom' ) ;
696
+ } )
697
+ . then ( function ( ) {
698
+ bottom = markerOffsetY ( ) ;
699
+ expect ( bottom ) . toBeGreaterThan ( middle ) ;
700
+ } )
701
+ . catch ( failTest )
702
+ . then ( done ) ;
703
+ } ) ;
704
+ } ) ;
668
705
} ) ;
669
706
670
707
describe ( 'legend orientation change:' , function ( ) {
0 commit comments