@@ -181,9 +181,12 @@ describe('main plot pan', function() {
181
181
describe ( 'axis zoom/pan and main plot zoom' , function ( ) {
182
182
var gd ;
183
183
184
+ beforeAll ( function ( ) {
185
+ jasmine . addMatchers ( customMatchers ) ;
186
+ } ) ;
187
+
184
188
beforeEach ( function ( ) {
185
189
gd = createGraphDiv ( ) ;
186
- jasmine . addMatchers ( customMatchers ) ;
187
190
} ) ;
188
191
189
192
afterEach ( destroyGraphDiv ) ;
@@ -240,11 +243,7 @@ describe('axis zoom/pan and main plot zoom', function() {
240
243
if ( layoutEdits ) Lib . extendDeep ( layout , layoutEdits ) ;
241
244
242
245
return Plotly . newPlot ( gd , data , layout , config ) . then ( function ( ) {
243
- [
244
- 'xaxis' , 'yaxis' , 'xaxis2' , 'yaxis2' , 'xaxis3' , 'yaxis3'
245
- ] . forEach ( function ( axName ) {
246
- expect ( gd . _fullLayout [ axName ] . range ) . toEqual ( initialRange ) ;
247
- } ) ;
246
+ checkRanges ( { } , 'initial' ) ;
248
247
249
248
expect ( Object . keys ( gd . _fullLayout . _plots ) )
250
249
. toEqual ( [ 'xy' , 'xy2' , 'x2y' , 'x3y3' ] ) ;
@@ -276,7 +275,9 @@ describe('axis zoom/pan and main plot zoom', function() {
276
275
return function ( ) { return doubleClick ( getDragger ( subplot , directions ) ) ; } ;
277
276
}
278
277
279
- function checkRanges ( newRanges ) {
278
+ function checkRanges ( newRanges , msg ) {
279
+ msg = msg || '' ;
280
+ if ( msg ) msg = ' - ' + msg ;
280
281
return function ( ) {
281
282
var allRanges = {
282
283
xaxis : initialRange . slice ( ) ,
@@ -289,8 +290,8 @@ describe('axis zoom/pan and main plot zoom', function() {
289
290
Lib . extendDeep ( allRanges , newRanges ) ;
290
291
291
292
for ( var axName in allRanges ) {
292
- expect ( gd . layout [ axName ] . range ) . toBeCloseToArray ( allRanges [ axName ] , 3 , axName ) ;
293
- expect ( gd . _fullLayout [ axName ] . range ) . toBeCloseToArray ( gd . layout [ axName ] . range , 6 , axName ) ;
293
+ expect ( gd . layout [ axName ] . range ) . toBeCloseToArray ( allRanges [ axName ] , 3 , axName + msg ) ;
294
+ expect ( gd . _fullLayout [ axName ] . range ) . toBeCloseToArray ( gd . layout [ axName ] . range , 6 , axName + msg ) ;
294
295
}
295
296
} ;
296
297
}
@@ -299,45 +300,45 @@ describe('axis zoom/pan and main plot zoom', function() {
299
300
makePlot ( )
300
301
// zoombox into a small point - drag starts from the center unless you specify otherwise
301
302
. then ( doDrag ( 'xy' , 'nsew' , 100 , - 50 ) )
302
- . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 1.5 ] } ) )
303
+ . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 1.5 ] } , 'zoombox' ) )
303
304
304
305
// first dblclick reverts to saved ranges
305
306
. then ( doDblClick ( 'xy' , 'nsew' ) )
306
- . then ( checkRanges ( ) )
307
+ . then ( checkRanges ( { } , 'dblclick #1' ) )
307
308
// next dblclick autoscales (just that plot)
308
309
. then ( doDblClick ( 'xy' , 'nsew' ) )
309
- . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange } ) )
310
+ . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange } , 'dblclick #2' ) )
310
311
// dblclick on one axis reverts just that axis to saved
311
312
. then ( doDblClick ( 'xy' , 'ns' ) )
312
- . then ( checkRanges ( { xaxis : autoRange } ) )
313
+ . then ( checkRanges ( { xaxis : autoRange } , 'dblclick y' ) )
313
314
// dblclick the plot at this point (one axis default, the other autoscaled)
314
315
// and the whole thing is reverted to default
315
316
. then ( doDblClick ( 'xy' , 'nsew' ) )
316
- . then ( checkRanges ( ) )
317
+ . then ( checkRanges ( { } , 'dblclick #3' ) )
317
318
318
319
// 1D zoombox - use the linked subplots
319
320
. then ( doDrag ( 'xy2' , 'nsew' , - 100 , 0 ) )
320
- . then ( checkRanges ( { xaxis : [ 0 , 1 ] } ) )
321
+ . then ( checkRanges ( { xaxis : [ 0 , 1 ] } , 'xy2 zoombox' ) )
321
322
. then ( doDrag ( 'x2y' , 'nsew' , 0 , 50 ) )
322
- . then ( checkRanges ( { xaxis : [ 0 , 1 ] , yaxis : [ 0.5 , 1 ] } ) )
323
+ . then ( checkRanges ( { xaxis : [ 0 , 1 ] , yaxis : [ 0.5 , 1 ] } , 'x2y zoombox' ) )
323
324
// dblclick on linked subplots just changes the linked axis
324
325
. then ( doDblClick ( 'xy2' , 'nsew' ) )
325
- . then ( checkRanges ( { yaxis : [ 0.5 , 1 ] } ) )
326
+ . then ( checkRanges ( { yaxis : [ 0.5 , 1 ] } , 'dblclick xy2' ) )
326
327
. then ( doDblClick ( 'x2y' , 'nsew' ) )
327
- . then ( checkRanges ( ) )
328
+ . then ( checkRanges ( { } , 'dblclick x2y' ) )
328
329
// drag on axis ends - all these 1D draggers the opposite axis delta is irrelevant
329
330
. then ( doDrag ( 'xy2' , 'n' , 53 , 100 ) )
330
- . then ( checkRanges ( { yaxis2 : [ 0 , 4 ] } ) )
331
+ . then ( checkRanges ( { yaxis2 : [ 0 , 4 ] } , 'drag y2n' ) )
331
332
. then ( doDrag ( 'xy' , 's' , 53 , - 100 ) )
332
- . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] } ) )
333
+ . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] } , 'drag ys' ) )
333
334
// expanding drag is highly nonlinear
334
335
. then ( doDrag ( 'x2y' , 'e' , 50 , 53 ) )
335
- . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0 , 0.8751 ] } ) )
336
+ . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0 , 0.8751 ] } , 'drag x2e' ) )
336
337
. then ( doDrag ( 'x2y' , 'w' , - 50 , 53 ) )
337
- . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0.4922 , 0.8751 ] } ) )
338
+ . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0.4922 , 0.8751 ] } , 'drag x2w' ) )
338
339
// reset all from the modebar
339
340
. then ( function ( ) { selectButton ( gd . _fullLayout . _modeBar , 'resetScale2d' ) . click ( ) ; } )
340
- . then ( checkRanges ( ) )
341
+ . then ( checkRanges ( { } , 'final reset' ) )
341
342
. catch ( failTest )
342
343
. then ( done ) ;
343
344
} ) ;
@@ -346,42 +347,42 @@ describe('axis zoom/pan and main plot zoom', function() {
346
347
makePlot ( )
347
348
// drag axis middles
348
349
. then ( doDrag ( 'x3y3' , 'ew' , 100 , 0 ) )
349
- . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] } ) )
350
+ . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] } , 'drag x3ew' ) )
350
351
. then ( doDrag ( 'x3y3' , 'ns' , 53 , 100 ) )
351
- . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] , yaxis3 : [ 1 , 3 ] } ) )
352
+ . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] , yaxis3 : [ 1 , 3 ] } , 'drag y3ns' ) )
352
353
// drag corners
353
354
. then ( doDrag ( 'x3y3' , 'ne' , - 100 , 100 ) )
354
- . then ( checkRanges ( { xaxis3 : [ - 1 , 3 ] , yaxis3 : [ 1 , 5 ] } ) )
355
+ . then ( checkRanges ( { xaxis3 : [ - 1 , 3 ] , yaxis3 : [ 1 , 5 ] } , 'zoom x3y3ne' ) )
355
356
. then ( doDrag ( 'x3y3' , 'sw' , 100 , - 100 ) )
356
- . then ( checkRanges ( { xaxis3 : [ - 5 , 3 ] , yaxis3 : [ - 3 , 5 ] } ) )
357
+ . then ( checkRanges ( { xaxis3 : [ - 5 , 3 ] , yaxis3 : [ - 3 , 5 ] } , 'zoom x3y3sw' ) )
357
358
. then ( doDrag ( 'x3y3' , 'nw' , - 50 , - 50 ) )
358
- . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 3 ] , yaxis3 : [ - 3 , 0.5006 ] } ) )
359
+ . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 3 ] , yaxis3 : [ - 3 , 0.5006 ] } , 'zoom x3y3nw' ) )
359
360
. then ( doDrag ( 'x3y3' , 'se' , 50 , 50 ) )
360
- . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 1.0312 ] , yaxis3 : [ - 1.0312 , 0.5006 ] } ) )
361
+ . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 1.0312 ] , yaxis3 : [ - 1.0312 , 0.5006 ] } , 'zoom x3y3se' ) )
361
362
. then ( doDblClick ( 'x3y3' , 'nsew' ) )
362
- . then ( checkRanges ( ) )
363
+ . then ( checkRanges ( { } , 'reset x3y3' ) )
363
364
// scroll wheel
364
365
. then ( function ( ) {
365
366
var mainDrag = getDragger ( 'xy' , 'nsew' ) ;
366
367
var mainDragCoords = getNodeCoords ( mainDrag , 'se' ) ;
367
368
mouseEvent ( 'scroll' , mainDragCoords . x , mainDragCoords . y , { deltaY : 20 , element : mainDrag } ) ;
368
369
} )
369
370
. then ( delay ( constants . REDRAWDELAY + 10 ) )
370
- . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] } ) )
371
+ . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] } , 'xy main scroll' ) )
371
372
. then ( function ( ) {
372
373
var ewDrag = getDragger ( 'xy' , 'ew' ) ;
373
374
var ewDragCoords = getNodeCoords ( ewDrag ) ;
374
375
mouseEvent ( 'scroll' , ewDragCoords . x - 50 , ewDragCoords . y , { deltaY : - 20 , element : ewDrag } ) ;
375
376
} )
376
377
. then ( delay ( constants . REDRAWDELAY + 10 ) )
377
- . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0 , 2.4428 ] } ) )
378
+ . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0 , 2.4428 ] } , 'x scroll' ) )
378
379
. then ( function ( ) {
379
380
var nsDrag = getDragger ( 'xy' , 'ns' ) ;
380
381
var nsDragCoords = getNodeCoords ( nsDrag ) ;
381
382
mouseEvent ( 'scroll' , nsDragCoords . x , nsDragCoords . y - 50 , { deltaY : - 20 , element : nsDrag } ) ;
382
383
} )
383
384
. then ( delay ( constants . REDRAWDELAY + 10 ) )
384
- . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.3321 , 2.3321 ] } ) )
385
+ . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.3321 , 2.3321 ] } , 'y scroll' ) )
385
386
. catch ( failTest )
386
387
. then ( done ) ;
387
388
} ) ;
@@ -390,44 +391,45 @@ describe('axis zoom/pan and main plot zoom', function() {
390
391
makePlot ( true )
391
392
// zoombox - this *would* be 1D (dy=-1) but that's not allowed
392
393
. then ( doDrag ( 'xy' , 'nsew' , 100 , - 1 ) )
393
- . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 2 ] , xaxis2 : [ 0.5 , 1.5 ] , yaxis2 : [ 0.5 , 1.5 ] } ) )
394
+ . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 2 ] , xaxis2 : [ 0.5 , 1.5 ] , yaxis2 : [ 0.5 , 1.5 ] } , 'zoombox xy' ) )
394
395
// first dblclick reverts to saved ranges
395
396
. then ( doDblClick ( 'xy' , 'nsew' ) )
396
- . then ( checkRanges ( ) )
397
+ . then ( checkRanges ( { } , 'dblclick xy' ) )
397
398
// next dblclick autoscales ALL linked plots
398
399
. then ( doDblClick ( 'xy' , 'ns' ) )
399
- . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange , xaxis2 : autoRange , yaxis2 : autoRange } ) )
400
+ . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange , xaxis2 : autoRange , yaxis2 : autoRange } , 'dblclick y' ) )
400
401
// revert again
401
402
. then ( doDblClick ( 'xy' , 'nsew' ) )
402
- . then ( checkRanges ( ) )
403
+ . then ( checkRanges ( { } , 'dblclick xy #2' ) )
403
404
// corner drag - full distance in one direction and no shift in the other gets averaged
404
405
// into half distance in each
405
406
. then ( doDrag ( 'xy' , 'ne' , - 200 , 0 ) )
406
- . then ( checkRanges ( { xaxis : [ 0 , 4 ] , yaxis : [ 0 , 4 ] , xaxis2 : [ - 1 , 3 ] , yaxis2 : [ - 1 , 3 ] } ) )
407
+ . then ( checkRanges ( { xaxis : [ 0 , 4 ] , yaxis : [ 0 , 4 ] , xaxis2 : [ - 1 , 3 ] , yaxis2 : [ - 1 , 3 ] } , 'zoom xy ne' ) )
407
408
// drag one end
408
409
. then ( doDrag ( 'xy' , 's' , 53 , - 100 ) )
409
- . then ( checkRanges ( { xaxis : [ - 2 , 6 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } ) )
410
+ . then ( checkRanges ( { xaxis : [ - 2 , 6 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } , 'zoom y s' ) )
410
411
// middle of an axis
411
412
. then ( doDrag ( 'xy' , 'ew' , - 100 , 53 ) )
412
- . then ( checkRanges ( { xaxis : [ 2 , 10 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } ) )
413
+ . then ( checkRanges ( { xaxis : [ 2 , 10 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } , 'drag x ew' ) )
413
414
// revert again
414
415
. then ( doDblClick ( 'xy' , 'nsew' ) )
415
- . then ( checkRanges ( ) )
416
+ . then ( checkRanges ( { } , 'dblclick xy #3' ) )
416
417
// scroll wheel
417
418
. then ( function ( ) {
418
419
var mainDrag = getDragger ( 'xy' , 'nsew' ) ;
419
420
var mainDragCoords = getNodeCoords ( mainDrag , 'se' ) ;
420
421
mouseEvent ( 'scroll' , mainDragCoords . x , mainDragCoords . y , { deltaY : 20 , element : mainDrag } ) ;
421
422
} )
422
423
. then ( delay ( constants . REDRAWDELAY + 10 ) )
423
- . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] , xaxis2 : [ - 0.2214 , 2.2214 ] , yaxis2 : [ - 0.2214 , 2.2214 ] } ) )
424
+ . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] , xaxis2 : [ - 0.2214 , 2.2214 ] , yaxis2 : [ - 0.2214 , 2.2214 ] } ,
425
+ 'scroll xy' ) )
424
426
. then ( function ( ) {
425
427
var ewDrag = getDragger ( 'xy' , 'ew' ) ;
426
428
var ewDragCoords = getNodeCoords ( ewDrag ) ;
427
429
mouseEvent ( 'scroll' , ewDragCoords . x - 50 , ewDragCoords . y , { deltaY : - 20 , element : ewDrag } ) ;
428
430
} )
429
431
. then ( delay ( constants . REDRAWDELAY + 10 ) )
430
- . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.2214 , 2.2214 ] } ) )
432
+ . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.2214 , 2.2214 ] } , 'scroll x' ) )
431
433
. catch ( failTest )
432
434
. then ( done ) ;
433
435
} ) ;
0 commit comments