@@ -5431,3 +5431,77 @@ describe('Test template:', function() {
5431
5431
. then ( done ) ;
5432
5432
} ) ;
5433
5433
} ) ;
5434
+
5435
+ describe ( 'more react tests' , function ( ) {
5436
+ var gd ;
5437
+
5438
+ beforeEach ( function ( ) {
5439
+ gd = createGraphDiv ( ) ;
5440
+ } ) ;
5441
+
5442
+ afterEach ( destroyGraphDiv ) ;
5443
+
5444
+ it ( 'should sort catgories on matching axes using react' , function ( done ) {
5445
+ var fig = {
5446
+ data : [ {
5447
+ yaxis : 'y' ,
5448
+ xaxis : 'x' ,
5449
+ y : [ 0 , 0 ] ,
5450
+ x : [ 'A' , 'Z' ]
5451
+ } , {
5452
+ yaxis : 'y2' ,
5453
+ xaxis : 'x2' ,
5454
+ y : [ 0 , 0 ] ,
5455
+ x : [ 'A' , 'Z' ]
5456
+ } ] ,
5457
+ layout : {
5458
+ width : 400 ,
5459
+ height : 300 ,
5460
+ showlegend : false ,
5461
+ xaxis : {
5462
+ matches : 'x2' ,
5463
+ domain : [ 0 , 1 ]
5464
+ } ,
5465
+ yaxis : {
5466
+ domain : [ 0.6 , 1 ] ,
5467
+ anchor : 'x'
5468
+ } ,
5469
+ xaxis2 : {
5470
+ domain : [ 0 , 1 ] ,
5471
+ anchor : 'y2'
5472
+ } ,
5473
+ yaxis2 : {
5474
+ domain : [ 0 , 0.4 ] ,
5475
+ anchor : 'x2'
5476
+ }
5477
+ }
5478
+ } ;
5479
+
5480
+ Plotly . newPlot ( gd , fig )
5481
+ . then ( function ( ) {
5482
+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'A' , 'Z' ] ) ;
5483
+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'A' , 'Z' ] ) ;
5484
+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { A : 0 , Z : 1 } ) ;
5485
+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { A : 0 , Z : 1 } ) ;
5486
+ } )
5487
+ . then ( function ( ) {
5488
+ var newFig = JSON . parse ( JSON . stringify ( fig ) ) ;
5489
+
5490
+ // flip order
5491
+ newFig . data [ 0 ] . x . reverse ( ) ;
5492
+ newFig . data [ 0 ] . y . reverse ( ) ;
5493
+ newFig . data [ 1 ] . x . reverse ( ) ;
5494
+ newFig . data [ 1 ] . y . reverse ( ) ;
5495
+
5496
+ return Plotly . react ( gd , newFig ) ;
5497
+ } )
5498
+ . then ( function ( ) {
5499
+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5500
+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5501
+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5502
+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5503
+ } )
5504
+ . catch ( failTest )
5505
+ . then ( done ) ;
5506
+ } ) ;
5507
+ } ) ;
0 commit comments