@@ -6,7 +6,7 @@ var doubleClick = require('../assets/double_click');
6
6
7
7
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
8
8
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
9
- var fail = require ( '../assets/fail_test' ) ;
9
+ var failTest = require ( '../assets/fail_test' ) ;
10
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
11
11
var touchEvent = require ( '../assets/touch_event' ) ;
12
12
@@ -190,7 +190,7 @@ describe('@flaky Test select box and lasso in general:', function() {
190
190
. then ( function ( ) {
191
191
expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
192
192
} )
193
- . catch ( fail )
193
+ . catch ( failTest )
194
194
. then ( done ) ;
195
195
} ) ;
196
196
@@ -282,7 +282,7 @@ describe('@flaky Test select box and lasso in general:', function() {
282
282
. then ( function ( ) {
283
283
expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
284
284
} )
285
- . catch ( fail )
285
+ . catch ( failTest )
286
286
. then ( done ) ;
287
287
} ) ;
288
288
@@ -336,7 +336,7 @@ describe('@flaky Test select box and lasso in general:', function() {
336
336
. then ( function ( ) {
337
337
expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
338
338
} )
339
- . catch ( fail )
339
+ . catch ( failTest )
340
340
. then ( done ) ;
341
341
} ) ;
342
342
@@ -355,7 +355,7 @@ describe('@flaky Test select box and lasso in general:', function() {
355
355
. then ( function ( ) {
356
356
expect ( gd . data [ 0 ] . selectedpoints ) . toBeUndefined ( ) ;
357
357
} )
358
- . catch ( fail )
358
+ . catch ( failTest )
359
359
. then ( done ) ;
360
360
} ) ;
361
361
@@ -374,7 +374,7 @@ describe('@flaky Test select box and lasso in general:', function() {
374
374
. then ( function ( ) {
375
375
expect ( gd . _fullData [ 0 ] . selectedpoints ) . toBeUndefined ( ) ;
376
376
} )
377
- . catch ( fail )
377
+ . catch ( failTest )
378
378
. then ( done ) ;
379
379
} ) ;
380
380
@@ -408,7 +408,7 @@ describe('@flaky Test select box and lasso in general:', function() {
408
408
. then ( function ( ) {
409
409
expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
410
410
} )
411
- . catch ( fail )
411
+ . catch ( failTest )
412
412
. then ( done ) ;
413
413
} ) ;
414
414
} ) ;
@@ -488,7 +488,7 @@ describe('@flaky Test select box and lasso in general:', function() {
488
488
. then ( function ( ) {
489
489
checkPointCount ( 0 , '(multiple invisible traces lasso)' ) ;
490
490
} )
491
- . catch ( fail )
491
+ . catch ( failTest )
492
492
. then ( done ) ;
493
493
} ) ;
494
494
@@ -527,7 +527,7 @@ describe('@flaky Test select box and lasso in general:', function() {
527
527
expect ( selectedData . points [ 0 ] . x ) . toBe ( 0 ) ;
528
528
expect ( selectedData . points [ 0 ] . y ) . toBe ( 0 ) ;
529
529
} )
530
- . catch ( fail )
530
+ . catch ( failTest )
531
531
. then ( done ) ;
532
532
} ) ;
533
533
@@ -549,7 +549,7 @@ describe('@flaky Test select box and lasso in general:', function() {
549
549
. then ( function ( ) {
550
550
assertSelectionNodes ( 0 , 0 ) ;
551
551
} )
552
- . catch ( fail )
552
+ . catch ( failTest )
553
553
. then ( done ) ;
554
554
} ) ;
555
555
} ) ;
@@ -730,7 +730,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
730
730
LASSOEVENTS , 'scatterternary lasso after relayout'
731
731
) ;
732
732
} )
733
- . catch ( fail )
733
+ . catch ( failTest )
734
734
. then ( done ) ;
735
735
} ) ;
736
736
@@ -766,7 +766,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
766
766
null , LASSOEVENTS , 'scattercarpet lasso'
767
767
) ;
768
768
} )
769
- . catch ( fail )
769
+ . catch ( failTest )
770
770
. then ( done ) ;
771
771
} ) ;
772
772
@@ -823,7 +823,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
823
823
[ [ 370 , 120 ] , [ 500 , 200 ] ] , null , null , NOEVENTS , 'scattermapbox pan'
824
824
) ;
825
825
} )
826
- . catch ( fail )
826
+ . catch ( failTest )
827
827
. then ( done ) ;
828
828
} , LONG_TIMEOUT_INTERVAL ) ;
829
829
@@ -889,7 +889,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
889
889
[ [ 370 , 120 ] , [ 500 , 200 ] ] , null , null , NOEVENTS , 'scattergeo pan'
890
890
) ;
891
891
} )
892
- . catch ( fail )
892
+ . catch ( failTest )
893
893
. then ( done ) ;
894
894
} , LONG_TIMEOUT_INTERVAL ) ;
895
895
@@ -927,7 +927,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
927
927
LASSOEVENTS , 'scatterpolar lasso'
928
928
) ;
929
929
} )
930
- . catch ( fail )
930
+ . catch ( failTest )
931
931
. then ( done ) ;
932
932
} ) ;
933
933
@@ -990,7 +990,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
990
990
[ [ 370 , 120 ] , [ 500 , 200 ] ] , null , [ 280 , 190 ] , NOEVENTS , 'choropleth pan'
991
991
) ;
992
992
} )
993
- . catch ( fail )
993
+ . catch ( failTest )
994
994
. then ( done ) ;
995
995
} , LONG_TIMEOUT_INTERVAL ) ;
996
996
@@ -1063,7 +1063,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
1063
1063
null , BOXEVENTS , 'bar select'
1064
1064
) ;
1065
1065
} )
1066
- . catch ( fail )
1066
+ . catch ( failTest )
1067
1067
. then ( done ) ;
1068
1068
} ) ;
1069
1069
@@ -1123,7 +1123,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
1123
1123
null , BOXEVENTS , 'date/category select'
1124
1124
) ;
1125
1125
} )
1126
- . catch ( fail )
1126
+ . catch ( failTest )
1127
1127
. then ( done ) ;
1128
1128
} ) ;
1129
1129
@@ -1172,7 +1172,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
1172
1172
null , BOXEVENTS , 'histogram select'
1173
1173
) ;
1174
1174
} )
1175
- . catch ( fail )
1175
+ . catch ( failTest )
1176
1176
. then ( done ) ;
1177
1177
} ) ;
1178
1178
@@ -1236,7 +1236,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
1236
1236
null , BOXEVENTS , 'box select'
1237
1237
) ;
1238
1238
} )
1239
- . catch ( fail )
1239
+ . catch ( failTest )
1240
1240
. then ( done ) ;
1241
1241
} ) ;
1242
1242
@@ -1299,10 +1299,77 @@ describe('@flaky Test select box and lasso per trace:', function() {
1299
1299
null , BOXEVENTS , 'violin select'
1300
1300
) ;
1301
1301
} )
1302
- . catch ( fail )
1302
+ . catch ( failTest )
1303
1303
. then ( done ) ;
1304
1304
} ) ;
1305
1305
1306
+ [ 'ohlc' , 'candlestick' ] . forEach ( function ( type ) {
1307
+ it ( 'should work for ' + type + ' traces' , function ( done ) {
1308
+ var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'x' , 'open' , 'high' , 'low' , 'close' ] ) ;
1309
+ var assertSelectedPoints = makeAssertSelectedPoints ( ) ;
1310
+ var assertRanges = makeAssertRanges ( ) ;
1311
+ var assertLassoPoints = makeAssertLassoPoints ( ) ;
1312
+ var l0 = 275 ;
1313
+ var lv0 = '2011-01-03 18:00' ;
1314
+ var r0 = 325 ;
1315
+ var rv0 = '2011-01-04 06:00' ;
1316
+ var l1 = 75 ;
1317
+ var lv1 = '2011-01-01 18:00' ;
1318
+ var r1 = 125 ;
1319
+ var rv1 = '2011-01-02 06:00' ;
1320
+ var t = 75 ;
1321
+ var tv = 8 ;
1322
+ var b = 325 ;
1323
+ var bv = - 2 ;
1324
+
1325
+ Plotly . newPlot ( gd , [ {
1326
+ type : type ,
1327
+ x : [ '2011-01-02' , '2011-01-03' , '2011-01-04' ] ,
1328
+ open : [ 1 , 2 , 3 ] ,
1329
+ high : [ 3 , 4 , 5 ] ,
1330
+ low : [ 0 , 1 , 2 ] ,
1331
+ close : [ 0 , 3 , 2 ]
1332
+ } ] , {
1333
+ width : 400 ,
1334
+ height : 400 ,
1335
+ margin : { l : 50 , r : 50 , t : 50 , b : 50 } ,
1336
+ yaxis : { range : [ - 3 , 9 ] } ,
1337
+ xaxis : { rangeslider : { visible : false } } ,
1338
+ dragmode : 'lasso'
1339
+ } )
1340
+ . then ( function ( ) {
1341
+ return _run (
1342
+ [ [ l0 , t ] , [ l0 , b ] , [ r0 , b ] , [ r0 , t ] , [ l0 , t ] ] ,
1343
+ function ( ) {
1344
+ assertPoints ( [ [ 0 , '2011-01-04' , 3 , 5 , 2 , 2 ] ] ) ;
1345
+ assertSelectedPoints ( [ [ 2 ] ] ) ;
1346
+ assertLassoPoints ( [
1347
+ [ lv0 , lv0 , rv0 , rv0 , lv0 ] ,
1348
+ [ tv , bv , bv , tv , tv ]
1349
+ ] ) ;
1350
+ } ,
1351
+ null , LASSOEVENTS , type + ' lasso'
1352
+ ) ;
1353
+ } )
1354
+ . then ( function ( ) {
1355
+ return Plotly . relayout ( gd , 'dragmode' , 'select' ) ;
1356
+ } )
1357
+ . then ( function ( ) {
1358
+ return _run (
1359
+ [ [ l1 , t ] , [ r1 , b ] ] ,
1360
+ function ( ) {
1361
+ assertPoints ( [ [ 0 , '2011-01-02' , 1 , 3 , 0 , 0 ] ] ) ;
1362
+ assertSelectedPoints ( [ [ 0 ] ] ) ;
1363
+ assertRanges ( [ [ lv1 , rv1 ] , [ bv , tv ] ] ) ;
1364
+ } ,
1365
+ null , BOXEVENTS , type + ' select'
1366
+ ) ;
1367
+ } )
1368
+ . catch ( failTest )
1369
+ . then ( done ) ;
1370
+ } ) ;
1371
+ } ) ;
1372
+
1306
1373
it ( 'should work on traces with enabled transforms' , function ( done ) {
1307
1374
var assertSelectedPoints = makeAssertSelectedPoints ( ) ;
1308
1375
@@ -1342,7 +1409,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
1342
1409
BOXEVENTS , 'transformed trace select (all points selected)'
1343
1410
) ;
1344
1411
} )
1345
- . catch ( fail )
1412
+ . catch ( failTest )
1346
1413
. then ( done ) ;
1347
1414
} ) ;
1348
1415
} ) ;
@@ -1399,7 +1466,7 @@ describe('Test that selections persist:', function() {
1399
1466
style : [ 0.2 , 1 , 0.2 ]
1400
1467
} ) ;
1401
1468
} )
1402
- . catch ( fail )
1469
+ . catch ( failTest )
1403
1470
. then ( done ) ;
1404
1471
} ) ;
1405
1472
@@ -1445,7 +1512,7 @@ describe('Test that selections persist:', function() {
1445
1512
style : [ 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 1 , 1 , 1 ] ,
1446
1513
} ) ;
1447
1514
} )
1448
- . catch ( fail )
1515
+ . catch ( failTest )
1449
1516
. then ( done ) ;
1450
1517
} ) ;
1451
1518
@@ -1487,7 +1554,7 @@ describe('Test that selections persist:', function() {
1487
1554
style : [ 0.2 , 1 , 0.2 , 0.2 , 0.2 ] ,
1488
1555
} ) ;
1489
1556
} )
1490
- . catch ( fail )
1557
+ . catch ( failTest )
1491
1558
. then ( done ) ;
1492
1559
} ) ;
1493
1560
} ) ;
0 commit comments