@@ -307,7 +307,7 @@ describe('Layout images', function() {
307
307
308
308
afterEach ( destroyGraphDiv ) ;
309
309
310
- it ( 'should properly add and removing image' , function ( done ) {
310
+ it ( 'should properly add and remove image' , function ( done ) {
311
311
var gd = createGraphDiv ( ) ,
312
312
data = [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
313
313
layout = { width : 500 , height : 400 } ;
@@ -425,23 +425,38 @@ describe('images log/linear axis changes', function() {
425
425
// we don't try to figure out the position on a new axis / canvas
426
426
// automatically when you change xref / yref, we leave it to the caller.
427
427
428
+ // initial clip path should end in 'xy' to match xref/yref
429
+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / x y \) $ / ) ;
430
+
428
431
// linear to log
429
432
Plotly . relayout ( gd , { 'images[0].yref' : 'y2' } )
430
433
. then ( function ( ) {
431
434
expect ( gd . layout . images [ 0 ] . y ) . toBe ( 1 ) ;
432
435
436
+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / x y 2 \) $ / ) ;
437
+
433
438
// log to paper
434
439
return Plotly . relayout ( gd , { 'images[0].yref' : 'paper' } ) ;
435
440
} )
436
441
. then ( function ( ) {
437
442
expect ( gd . layout . images [ 0 ] . y ) . toBe ( 1 ) ;
438
443
444
+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / x \) $ / ) ;
445
+
446
+ // change to full paper-referenced, to make sure the clip path disappears
447
+ return Plotly . relayout ( gd , { 'images[0].xref' : 'paper' } ) ;
448
+ } )
449
+ . then ( function ( ) {
450
+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) ) . toBe ( null ) ;
451
+
439
452
// paper to log
440
453
return Plotly . relayout ( gd , { 'images[0].yref' : 'y2' } ) ;
441
454
} )
442
455
. then ( function ( ) {
443
456
expect ( gd . layout . images [ 0 ] . y ) . toBe ( 1 ) ;
444
457
458
+ expect ( d3 . select ( 'image' ) . attr ( 'clip-path' ) || '' ) . toMatch ( / ^ [ ^ x ] + y 2 \) $ / ) ;
459
+
445
460
// log to linear
446
461
return Plotly . relayout ( gd , { 'images[0].yref' : 'y' } ) ;
447
462
} )
0 commit comments