@@ -349,6 +349,49 @@ describe('Test gl2d lasso/select:', function() {
349
349
} )
350
350
. then ( done , done . fail ) ;
351
351
} ) ;
352
+
353
+ [
354
+ [ 'linear' , [ 1 , 2 , 3 ] ] ,
355
+ [ 'log' , [ 1 , 2 , 3 ] ] ,
356
+ [ 'category' , [ 'A' , 'B' , 'C' ] ] ,
357
+ [ 'date' , [ '1900-01-01' , '2000-01-01' , '2100-01-01' ] ]
358
+ ] . forEach ( function ( test ) {
359
+ var axType = test [ 0 ] ;
360
+ var x = test [ 1 ] ;
361
+ it ( '@gl should return the same eventData as scatter on ' + axType + ' axis' , function ( done ) {
362
+ var _mock = {
363
+ data : [ { type : 'scatter' , x : x , y : [ 6 , 5 , 4 ] } ] ,
364
+ layout : { dragmode : 'select' , width : 400 , height : 400 , xaxis : { type : axType } }
365
+ } ;
366
+ gd = createGraphDiv ( ) ;
367
+ var scatterEventData = { } ;
368
+ var selectPath = [ [ 150 , 150 ] , [ 250 , 250 ] ] ;
369
+
370
+ Plotly . newPlot ( gd , _mock )
371
+ . then ( delay ( 20 ) )
372
+ . then ( function ( ) {
373
+ expect ( gd . _fullLayout . xaxis . type ) . toEqual ( test [ 0 ] ) ;
374
+ return select ( gd , selectPath ) ;
375
+ } )
376
+ . then ( delay ( 20 ) )
377
+ . then ( function ( eventData ) {
378
+ scatterEventData = eventData ;
379
+ // Make sure we selected a point
380
+ expect ( eventData . points . length ) . toBe ( 1 ) ;
381
+ return Plotly . restyle ( gd , 'type' , 'scattergl' ) ;
382
+ } )
383
+ . then ( delay ( 20 ) )
384
+ . then ( function ( ) {
385
+ expect ( gd . _fullLayout . xaxis . type ) . toEqual ( test [ 0 ] ) ;
386
+ return select ( gd , selectPath ) ;
387
+ } )
388
+ . then ( delay ( 20 ) )
389
+ . then ( function ( eventData ) {
390
+ assertEventData ( eventData , scatterEventData ) ;
391
+ } )
392
+ . then ( done , done . fail ) ;
393
+ } ) ;
394
+ } ) ;
352
395
} ) ;
353
396
354
397
describe ( 'Test displayed selections:' , function ( ) {
0 commit comments