@@ -5485,22 +5485,78 @@ describe('more react tests', function() {
5485
5485
expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { A : 0 , Z : 1 } ) ;
5486
5486
} )
5487
5487
. then ( function ( ) {
5488
- var newFig = JSON . parse ( JSON . stringify ( fig ) ) ;
5489
-
5490
5488
// 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 ( ) ;
5489
+ fig . data [ 0 ] . x = [ 'Z' , 'A' ] ;
5490
+ fig . data [ 1 ] . x = [ 'Z' , 'A' ] ;
5495
5491
5496
- return Plotly . react ( gd , newFig ) ;
5492
+ return Plotly . react ( gd , fig ) ;
5493
+ } )
5494
+ . then ( function ( ) {
5495
+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5496
+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5497
+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5498
+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5499
+ } )
5500
+ . then ( function ( ) {
5501
+ // should get the same order with newPlot
5502
+ return Plotly . newPlot ( gd , fig ) ;
5497
5503
} )
5498
5504
. then ( function ( ) {
5499
5505
expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5500
5506
expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5501
5507
expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5502
5508
expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5503
5509
} )
5510
+ . then ( function ( ) {
5511
+ // add new category
5512
+ fig . data [ 0 ] . x = [ 'Z' , 0 , 'A' ] ;
5513
+ fig . data [ 1 ] . x = [ 'Z' , 0 , 'A' ] ;
5514
+ fig . data [ 0 ] . y = [ 1 , 2 , 3 ] ;
5515
+ fig . data [ 1 ] . y = [ 2 , 4 , 6 ] ;
5516
+
5517
+ return Plotly . react ( gd , fig ) ;
5518
+ } )
5519
+ . then ( function ( ) {
5520
+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5521
+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5522
+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5523
+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5524
+ } )
5525
+ . then ( function ( ) {
5526
+ // should get the same order with newPlot
5527
+ return Plotly . newPlot ( gd , fig ) ;
5528
+ } )
5529
+ . then ( function ( ) {
5530
+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5531
+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5532
+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5533
+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5534
+ } )
5535
+ . then ( function ( ) {
5536
+ // change data
5537
+ fig . data [ 0 ] . x = [ 'Z' , 0 , 'A' ] ;
5538
+ fig . data [ 1 ] . x = [ 'A' , 'Z' ] ;
5539
+ fig . data [ 0 ] . y = [ 3 , 2 , 1 ] ;
5540
+ fig . data [ 1 ] . y = [ - 1 , 0 ] ;
5541
+
5542
+ return Plotly . react ( gd , fig ) ;
5543
+ } )
5544
+ . then ( function ( ) {
5545
+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5546
+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5547
+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5548
+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5549
+ } )
5550
+ . then ( function ( ) {
5551
+ // should get the same order with newPlot
5552
+ return Plotly . newPlot ( gd , fig ) ;
5553
+ } )
5554
+ . then ( function ( ) {
5555
+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5556
+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5557
+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5558
+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5559
+ } )
5504
5560
. catch ( failTest )
5505
5561
. then ( done ) ;
5506
5562
} ) ;
0 commit comments