@@ -474,43 +474,43 @@ describe('annotations log/linear axis changes', function() {
474474
475475} ) ;
476476
477- describe ( 'annotations autosize ' , function ( ) {
477+ describe ( 'annotations autorange ' , function ( ) {
478478 'use strict' ;
479479
480480 var mock = Lib . extendDeep ( { } , require ( '@mocks/annotations-autorange.json' ) ) ;
481481 var gd ;
482482
483483 beforeAll ( function ( ) {
484484 jasmine . addMatchers ( customMatchers ) ;
485+
486+ gd = createGraphDiv ( ) ;
485487 } ) ;
486488
487489 afterEach ( destroyGraphDiv ) ;
488490
489- it ( 'should adapt to relayout calls' , function ( done ) {
490- gd = createGraphDiv ( ) ;
491-
492- function assertRanges ( x , y , x2 , y2 , x3 , y3 ) {
493- var fullLayout = gd . _fullLayout ;
494- var PREC = 1 ;
495-
496- // xaxis2 need a bit more tolerance to pass on CI
497- // this most likely due to the different text bounding box values
498- // on headfull vs headless browsers.
499- // but also because it's a date axis that we've converted to ms
500- var PRECX2 = - 10 ;
501- // yaxis2 needs a bit more now too...
502- var PRECY2 = 0.2 ;
503- var dateAx = fullLayout . xaxis2 ;
504-
505- expect ( fullLayout . xaxis . range ) . toBeCloseToArray ( x , PREC , '- xaxis' ) ;
506- expect ( fullLayout . yaxis . range ) . toBeCloseToArray ( y , PREC , '- yaxis' ) ;
507- expect ( Lib . simpleMap ( dateAx . range , dateAx . r2l ) )
508- . toBeCloseToArray ( Lib . simpleMap ( x2 , dateAx . r2l ) , PRECX2 , 'xaxis2 ' + dateAx . range ) ;
509- expect ( fullLayout . yaxis2 . range ) . toBeCloseToArray ( y2 , PRECY2 , 'yaxis2' ) ;
510- expect ( fullLayout . xaxis3 . range ) . toBeCloseToArray ( x3 , PREC , 'xaxis3' ) ;
511- expect ( fullLayout . yaxis3 . range ) . toBeCloseToArray ( y3 , PREC , 'yaxis3' ) ;
512- }
491+ function assertRanges ( x , y , x2 , y2 , x3 , y3 ) {
492+ var fullLayout = gd . _fullLayout ;
493+ var PREC = 1 ;
494+
495+ // xaxis2 need a bit more tolerance to pass on CI
496+ // this most likely due to the different text bounding box values
497+ // on headfull vs headless browsers.
498+ // but also because it's a date axis that we've converted to ms
499+ var PRECX2 = - 10 ;
500+ // yaxis2 needs a bit more now too...
501+ var PRECY2 = 0.2 ;
502+ var dateAx = fullLayout . xaxis2 ;
503+
504+ expect ( fullLayout . xaxis . range ) . toBeCloseToArray ( x , PREC , '- xaxis' ) ;
505+ expect ( fullLayout . yaxis . range ) . toBeCloseToArray ( y , PREC , '- yaxis' ) ;
506+ expect ( Lib . simpleMap ( dateAx . range , dateAx . r2l ) )
507+ . toBeCloseToArray ( Lib . simpleMap ( x2 , dateAx . r2l ) , PRECX2 , 'xaxis2 ' + dateAx . range ) ;
508+ expect ( fullLayout . yaxis2 . range ) . toBeCloseToArray ( y2 , PRECY2 , 'yaxis2' ) ;
509+ expect ( fullLayout . xaxis3 . range ) . toBeCloseToArray ( x3 , PREC , 'xaxis3' ) ;
510+ expect ( fullLayout . yaxis3 . range ) . toBeCloseToArray ( y3 , PREC , 'yaxis3' ) ;
511+ }
513512
513+ it ( 'should adapt to relayout calls' , function ( done ) {
514514 Plotly . plot ( gd , mock ) . then ( function ( ) {
515515 assertRanges (
516516 [ 0.97 , 2.03 ] , [ 0.97 , 2.03 ] ,
@@ -563,6 +563,30 @@ describe('annotations autosize', function() {
563563 . catch ( failTest )
564564 . then ( done ) ;
565565 } ) ;
566+
567+ it ( 'catches bad xref/yref' , function ( done ) {
568+ Plotly . plot ( gd , mock ) . then ( function ( ) {
569+ return Plotly . relayout ( gd , { 'annotations[1]' : {
570+ text : 'LT' ,
571+ x : - 1 ,
572+ y : 3 ,
573+ xref : 'x5' , // will be converted to 'x' and xaxis should autorange
574+ yref : 'y5' , // same 'y' -> yaxis
575+ ax : 50 ,
576+ ay : 50
577+ } } ) ;
578+ } )
579+ . then ( function ( ) {
580+ assertRanges (
581+ [ - 1.09 , 2.09 ] , [ 0.94 , 3.06 ] ,
582+ // the other axes shouldn't change
583+ [ '2000-10-01 08:23:18.0583' , '2001-06-05 19:20:23.301' ] , [ - 0.245 , 4.245 ] ,
584+ [ 0.9 , 2.1 ] , [ 0.86 , 2.14 ]
585+ ) ;
586+ } )
587+ . catch ( failTest )
588+ . then ( done ) ;
589+ } ) ;
566590} ) ;
567591
568592describe ( 'annotation clicktoshow' , function ( ) {
0 commit comments