@@ -7,6 +7,7 @@ var Drawing = require('@src/components/drawing');
77
88var createGraphDiv = require ( '../assets/create_graph_div' ) ;
99var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
10+ var fail = require ( '../assets/fail_test' ) ;
1011var mouseEvent = require ( '../assets/mouse_event' ) ;
1112var selectButton = require ( '../assets/modebar_button' ) ;
1213var customMatchers = require ( '../assets/custom_matchers' ) ;
@@ -631,6 +632,72 @@ describe('Test gl3d drag and wheel interactions', function() {
631632 } ) ;
632633} ) ;
633634
635+ describe ( 'Test gl3d relayout calls' , function ( ) {
636+ var gd ;
637+
638+ beforeEach ( function ( ) {
639+ gd = createGraphDiv ( ) ;
640+ } ) ;
641+
642+ afterEach ( function ( ) {
643+ Plotly . purge ( gd ) ;
644+ destroyGraphDiv ( ) ;
645+ } ) ;
646+
647+ it ( 'should be able to adjust margins' , function ( done ) {
648+ var w = 500 ;
649+ var h = 500 ;
650+
651+ function assertMargins ( t , l , b , r ) {
652+ var div3d = document . getElementById ( 'scene' ) ;
653+ expect ( parseFloat ( div3d . style . top ) ) . toEqual ( t , 'top' ) ;
654+ expect ( parseFloat ( div3d . style . left ) ) . toEqual ( l , 'left' ) ;
655+ expect ( h - parseFloat ( div3d . style . height ) - t ) . toEqual ( b , 'bottom' ) ;
656+ expect ( w - parseFloat ( div3d . style . width ) - l ) . toEqual ( r , 'right' ) ;
657+ }
658+
659+ Plotly . newPlot ( gd , [ {
660+ type : 'scatter3d' ,
661+ x : [ 1 , 2 , 3 ] ,
662+ y : [ 1 , 2 , 3 ] ,
663+ z : [ 1 , 2 , 1 ]
664+ } ] , {
665+ width : w ,
666+ height : h
667+ } )
668+ . then ( function ( ) {
669+ assertMargins ( 100 , 80 , 80 , 80 ) ;
670+
671+ return Plotly . relayout ( gd , 'margin' , {
672+ l : 0 , t : 0 , r : 0 , b : 0
673+ } ) ;
674+ } )
675+ . then ( function ( ) {
676+ assertMargins ( 0 , 0 , 0 , 0 ) ;
677+ } )
678+ . catch ( fail )
679+ . then ( done ) ;
680+ } ) ;
681+
682+ it ( 'should skip root-level axis objects' , function ( done ) {
683+ Plotly . newPlot ( gd , [ {
684+ type : 'scatter3d' ,
685+ x : [ 1 , 2 , 3 ] ,
686+ y : [ 1 , 2 , 3 ] ,
687+ z : [ 1 , 2 , 1 ]
688+ } ] )
689+ . then ( function ( ) {
690+ return Plotly . relayout ( gd , {
691+ xaxis : { } ,
692+ yaxis : { } ,
693+ zaxis : { }
694+ } ) ;
695+ } )
696+ . catch ( fail )
697+ . then ( done ) ;
698+ } ) ;
699+ } ) ;
700+
634701describe ( 'Test gl2d plots' , function ( ) {
635702 var gd ;
636703
0 commit comments