@@ -6,6 +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
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
10
11
var customMatchers = require ( '../assets/custom_matchers' ) ;
11
12
@@ -368,4 +369,55 @@ describe('select box and lasso', function() {
368
369
} )
369
370
. then ( done ) ;
370
371
} ) ;
372
+
373
+ it ( 'should work on scatterternary traces' , function ( done ) {
374
+ var fig = Lib . extendDeep ( { } , require ( '@mocks/ternary_simple' ) ) ;
375
+ var gd = createGraphDiv ( ) ;
376
+ var pts = [ ] ;
377
+
378
+ fig . layout . width = 800 ;
379
+ fig . layout . dragmode = 'select' ;
380
+
381
+ function assertPoints ( expected ) {
382
+ expect ( pts . length ) . toBe ( expected . length , 'selected points length' ) ;
383
+
384
+ pts . forEach ( function ( p , i ) {
385
+ var e = expected [ i ] ;
386
+ expect ( p . a ) . toBe ( e . a , 'selected pt a val' ) ;
387
+ expect ( p . b ) . toBe ( e . b , 'selected pt b val' ) ;
388
+ expect ( p . c ) . toBe ( e . c , 'selected pt c val' ) ;
389
+ } ) ;
390
+ pts = [ ] ;
391
+ }
392
+
393
+ Plotly . plot ( gd , fig ) . then ( function ( ) {
394
+ gd . on ( 'plotly_selected' , function ( data ) {
395
+ pts = data . points ;
396
+ } ) ;
397
+
398
+ assertSelectionNodes ( 0 , 0 ) ;
399
+ drag ( [ [ 400 , 200 ] , [ 445 , 235 ] ] ) ;
400
+ assertSelectionNodes ( 0 , 2 ) ;
401
+ assertPoints ( [ { a : 0.5 , b : 0.25 , c : 0.25 } ] ) ;
402
+
403
+ return Plotly . relayout ( gd , 'dragmode' , 'lasso' ) ;
404
+ } )
405
+ . then ( function ( ) {
406
+ assertSelectionNodes ( 0 , 0 ) ;
407
+ drag ( [ [ 400 , 200 ] , [ 445 , 200 ] , [ 445 , 235 ] , [ 400 , 235 ] , [ 400 , 200 ] ] ) ;
408
+ assertSelectionNodes ( 0 , 2 ) ;
409
+ assertPoints ( [ { a : 0.5 , b : 0.25 , c : 0.25 } ] ) ;
410
+
411
+ // should work after a relayout too
412
+ return Plotly . relayout ( gd , 'width' , 400 ) ;
413
+ } )
414
+ . then ( function ( ) {
415
+ assertSelectionNodes ( 0 , 0 ) ;
416
+ drag ( [ [ 200 , 200 ] , [ 230 , 200 ] , [ 230 , 230 ] , [ 200 , 230 ] , [ 200 , 200 ] ] ) ;
417
+ assertSelectionNodes ( 0 , 2 ) ;
418
+ assertPoints ( [ { a : 0.5 , b : 0.25 , c : 0.25 } ] ) ;
419
+ } )
420
+ . catch ( fail )
421
+ . then ( done ) ;
422
+ } ) ;
371
423
} ) ;
0 commit comments