@@ -11,6 +11,24 @@ var delay = require('../assets/delay');
11
11
var mouseEvent = require ( '../assets/mouse_event' ) ;
12
12
var readPixel = require ( '../assets/read_pixel' ) ;
13
13
14
+ function _newPlot ( gd , arg2 , arg3 , arg4 ) {
15
+ var fig ;
16
+ if ( Array . isArray ( arg2 ) ) {
17
+ fig = {
18
+ data : arg2 ,
19
+ layout : arg3 ,
20
+ config : arg4
21
+ } ;
22
+ } else fig = arg2 ;
23
+
24
+ if ( ! fig . layout ) fig . layout = { } ;
25
+ if ( ! fig . layout . newselection ) fig . layout . newselection = { } ;
26
+ fig . layout . newselection . mode = 'gradual' ;
27
+ // complex ouline creation are mainly tested in "gradual" mode here
28
+
29
+ return Plotly . newPlot ( gd , fig ) ;
30
+ }
31
+
14
32
function drag ( gd , path ) {
15
33
var len = path . length ;
16
34
var el = d3Select ( gd ) . select ( 'rect.nsewdrag' ) . node ( ) ;
@@ -87,7 +105,7 @@ describe('Test gl2d lasso/select:', function() {
87
105
_mock . layout . dragmode = 'select' ;
88
106
gd = createGraphDiv ( ) ;
89
107
90
- Plotly . newPlot ( gd , _mock )
108
+ _newPlot ( gd , _mock )
91
109
. then ( delay ( 20 ) )
92
110
. then ( function ( ) {
93
111
expect ( gd . _fullLayout . _plots . xy . _scene . select2d ) . not . toBe ( undefined , 'scatter2d renderer' ) ;
@@ -112,7 +130,7 @@ describe('Test gl2d lasso/select:', function() {
112
130
_mock . layout . dragmode = 'lasso' ;
113
131
gd = createGraphDiv ( ) ;
114
132
115
- Plotly . newPlot ( gd , _mock )
133
+ _newPlot ( gd , _mock )
116
134
. then ( delay ( 20 ) )
117
135
. then ( function ( ) {
118
136
return select ( gd , lassoPath2 ) ;
@@ -135,7 +153,7 @@ describe('Test gl2d lasso/select:', function() {
135
153
_mock . layout . dragmode = 'select' ;
136
154
gd = createGraphDiv ( ) ;
137
155
138
- Plotly . newPlot ( gd , _mock )
156
+ _newPlot ( gd , _mock )
139
157
. then ( delay ( 20 ) )
140
158
. then ( function ( ) {
141
159
return select ( gd , selectPath2 ) ;
@@ -154,7 +172,7 @@ describe('Test gl2d lasso/select:', function() {
154
172
_mock . layout . dragmode = 'lasso' ;
155
173
gd = createGraphDiv ( ) ;
156
174
157
- Plotly . newPlot ( gd , _mock )
175
+ _newPlot ( gd , _mock )
158
176
. then ( delay ( 20 ) )
159
177
. then ( function ( ) {
160
178
return select ( gd , lassoPath ) ;
@@ -175,7 +193,7 @@ describe('Test gl2d lasso/select:', function() {
175
193
fig . layout . width = 500 ;
176
194
gd = createGraphDiv ( ) ;
177
195
178
- Plotly . newPlot ( gd , fig )
196
+ _newPlot ( gd , fig )
179
197
. then ( delay ( 20 ) )
180
198
. then ( function ( ) { return select ( gd , [ [ 100 , 100 ] , [ 250 , 250 ] ] ) ; } )
181
199
. then ( function ( eventData ) {
@@ -205,7 +223,7 @@ describe('Test gl2d lasso/select:', function() {
205
223
} ) ;
206
224
}
207
225
208
- Plotly . newPlot ( gd , fig )
226
+ _newPlot ( gd , fig )
209
227
. then ( delay ( 20 ) )
210
228
. then ( function ( ) {
211
229
_assertGlTextOpts ( 'base' , {
@@ -287,7 +305,7 @@ describe('Test gl2d lasso/select:', function() {
287
305
} ) ;
288
306
}
289
307
290
- Plotly . newPlot ( gd , fig )
308
+ _newPlot ( gd , fig )
291
309
. then ( delay ( 20 ) )
292
310
. then ( function ( ) {
293
311
_assertGlTextOpts ( 'base' , {
@@ -370,7 +388,7 @@ describe('Test gl2d lasso/select:', function() {
370
388
var scatterEventData = { } ;
371
389
var selectPath = [ [ 150 , 150 ] , [ 250 , 250 ] ] ;
372
390
373
- Plotly . newPlot ( gd , _mock )
391
+ _newPlot ( gd , _mock )
374
392
. then ( delay ( 20 ) )
375
393
. then ( function ( ) {
376
394
expect ( gd . _fullLayout [ ax + 'axis' ] . type ) . toEqual ( test [ 0 ] ) ;
@@ -428,7 +446,7 @@ describe('Test displayed selections:', function() {
428
446
429
447
function readFocus ( ) { return _read ( '.gl-canvas-focus' ) ; }
430
448
431
- Plotly . newPlot ( gd , [ {
449
+ _newPlot ( gd , [ {
432
450
type : 'scattergl' ,
433
451
mode : 'markers' ,
434
452
y : [ 2 , 1 , 2 ]
@@ -488,7 +506,7 @@ describe('Test displayed selections:', function() {
488
506
}
489
507
} ;
490
508
491
- Plotly . newPlot ( gd , mock )
509
+ _newPlot ( gd , mock )
492
510
. then ( select ( gd , [ [ 160 , 100 ] , [ 180 , 100 ] ] ) )
493
511
. then ( function ( ) {
494
512
expect ( readPixel ( gd . querySelector ( '.gl-canvas-context' ) , 168 , 100 ) [ 3 ] ) . toBe ( 0 ) ;
@@ -533,7 +551,7 @@ describe('Test displayed selections:', function() {
533
551
}
534
552
} ;
535
553
536
- Plotly . newPlot ( gd , mock )
554
+ _newPlot ( gd , mock )
537
555
. then ( select ( gd , [ [ 160 , 100 ] , [ 180 , 100 ] ] ) )
538
556
. then ( function ( ) {
539
557
expect ( readPixel ( gd . querySelector ( '.gl-canvas-context' ) , 168 , 100 ) [ 3 ] ) . toBe ( 0 ) ;
@@ -622,7 +640,7 @@ describe('Test selections during funky scenarios', function() {
622
640
it ( '@gl should behave correctly when doubleclick before selecting anything' , function ( done ) {
623
641
gd = createGraphDiv ( ) ;
624
642
625
- Plotly . newPlot ( gd , [ {
643
+ _newPlot ( gd , [ {
626
644
type : 'scattergl' ,
627
645
mode : 'markers' ,
628
646
y : [ 1 , 2 , 1 ] ,
@@ -678,7 +696,7 @@ describe('Test selections during funky scenarios', function() {
678
696
tracker = [ ] ;
679
697
}
680
698
681
- Plotly . newPlot ( gd , [ {
699
+ _newPlot ( gd , [ {
682
700
type : 'scattergl' ,
683
701
mode : 'markers' ,
684
702
y : [ 1 , 2 , 1 ] ,
@@ -730,7 +748,7 @@ describe('Test selections during funky scenarios', function() {
730
748
731
749
var scene , scene2 ;
732
750
733
- Plotly . newPlot ( gd , [ {
751
+ _newPlot ( gd , [ {
734
752
x : [ 1 , 2 , 3 ] ,
735
753
y : [ 40 , 50 , 60 ] ,
736
754
type : 'scattergl' ,
0 commit comments