@@ -116,7 +116,6 @@ function calc(gd, trace) {
116
116
opts . marker . snap = stash . tree || TOO_MANY_POINTS ;
117
117
}
118
118
119
- // save scene opts batch
120
119
scene . lineOptions . push ( opts . line ) ;
121
120
scene . errorXOptions . push ( opts . errorX ) ;
122
121
scene . errorYOptions . push ( opts . errorY ) ;
@@ -128,7 +127,6 @@ function calc(gd, trace) {
128
127
scene . textSelectedOptions . push ( opts . textSel ) ;
129
128
scene . textUnselectedOptions . push ( opts . textUnsel ) ;
130
129
131
- // stash scene ref
132
130
stash . _scene = scene ;
133
131
stash . index = scene . count ;
134
132
stash . x = x ;
@@ -146,7 +144,6 @@ function expandForErrorBars(trace, ax, opts) {
146
144
extremes . max = extremes . max . concat ( errExt . max ) ;
147
145
}
148
146
149
- // create scene options
150
147
function sceneOptions ( gd , subplot , trace , positions , x , y ) {
151
148
var opts = convert . style ( gd , trace ) ;
152
149
@@ -193,13 +190,12 @@ function sceneOptions(gd, subplot, trace, positions, x, y) {
193
190
return opts ;
194
191
}
195
192
196
-
197
193
// make sure scene exists on subplot, return it
198
194
function sceneUpdate ( gd , subplot ) {
199
195
var scene = subplot . _scene ;
200
196
201
197
var resetOpts = {
202
- // number of traces in subplot, since scene:subplot → 1:1
198
+ // number of traces in subplot, since scene:subplot -> 1:1
203
199
count : 0 ,
204
200
// whether scene requires init hook in plot call (dirty plot call)
205
201
dirty : true ,
@@ -216,16 +212,16 @@ function sceneUpdate(gd, subplot) {
216
212
textUnselectedOptions : [ ]
217
213
} ;
218
214
215
+ // regl- component stubs, initialized in dirty plot call
219
216
var initOpts = {
220
217
selectBatch : null ,
221
218
unselectBatch : null ,
222
- // regl- component stubs, initialized in dirty plot call
223
219
fill2d : false ,
224
220
scatter2d : false ,
225
221
error2d : false ,
226
222
line2d : false ,
227
223
glText : false ,
228
- select2d : null
224
+ select2d : false
229
225
} ;
230
226
231
227
if ( ! subplot . _scene ) {
@@ -325,7 +321,7 @@ function sceneUpdate(gd, subplot) {
325
321
} ;
326
322
}
327
323
328
- // In case if we have scene from the last calc - reset data
324
+ // in case if we have scene from the last calc - reset data
329
325
if ( ! scene . dirty ) {
330
326
Lib . extendFlat ( scene , resetOpts ) ;
331
327
}
@@ -363,6 +359,7 @@ function plot(gd, subplot, cdata) {
363
359
return ;
364
360
}
365
361
362
+ var count = scene . count ;
366
363
var regl = fullLayout . _glcanvas . data ( ) [ 0 ] . regl ;
367
364
368
365
// that is needed for fills
@@ -383,28 +380,28 @@ function plot(gd, subplot, cdata) {
383
380
scene . fill2d = createLine ( regl ) ;
384
381
}
385
382
if ( scene . glText === true ) {
386
- scene . glText = new Array ( scene . count ) ;
387
- for ( i = 0 ; i < scene . count ; i ++ ) {
383
+ scene . glText = new Array ( count ) ;
384
+ for ( i = 0 ; i < count ; i ++ ) {
388
385
scene . glText [ i ] = new Text ( regl ) ;
389
386
}
390
387
}
391
388
392
389
// update main marker options
393
390
if ( scene . glText ) {
394
- if ( scene . count > scene . glText . length ) {
391
+ if ( count > scene . glText . length ) {
395
392
// add gl text marker
396
- var textsToAdd = scene . count - scene . glText . length ;
393
+ var textsToAdd = count - scene . glText . length ;
397
394
for ( i = 0 ; i < textsToAdd ; i ++ ) {
398
395
scene . glText . push ( new Text ( regl ) ) ;
399
396
}
400
- } else if ( scene . count < scene . glText . length ) {
397
+ } else if ( count < scene . glText . length ) {
401
398
// remove gl text marker
402
- var textsToRemove = scene . glText . length - scene . count ;
403
- var removedTexts = scene . glText . splice ( scene . count , textsToRemove ) ;
399
+ var textsToRemove = scene . glText . length - count ;
400
+ var removedTexts = scene . glText . splice ( count , textsToRemove ) ;
404
401
removedTexts . forEach ( function ( text ) { text . destroy ( ) ; } ) ;
405
402
}
406
403
407
- for ( i = 0 ; i < scene . count ; i ++ ) {
404
+ for ( i = 0 ; i < count ; i ++ ) {
408
405
scene . glText [ i ] . update ( scene . textOptions [ i ] ) ;
409
406
}
410
407
}
@@ -437,7 +434,7 @@ function plot(gd, subplot, cdata) {
437
434
}
438
435
439
436
// fill requires linked traces, so we generate it's positions here
440
- scene . fillOrder = Lib . repeat ( null , scene . count ) ;
437
+ scene . fillOrder = Lib . repeat ( null , count ) ;
441
438
if ( scene . fill2d ) {
442
439
scene . fillOptions = scene . fillOptions . map ( function ( fillOptions , i ) {
443
440
var cdscatter = cdata [ i ] ;
@@ -562,7 +559,7 @@ function plot(gd, subplot, cdata) {
562
559
var selectMode = dragmode === 'lasso' || dragmode === 'select' ;
563
560
var clickSelectEnabled = fullLayout . clickmode . indexOf ( 'select' ) > - 1 ;
564
561
565
- for ( i = 0 ; i < cdata . length ; i ++ ) {
562
+ for ( i = 0 ; i < count ; i ++ ) {
566
563
var cd0 = cdata [ i ] [ 0 ] ;
567
564
var trace = cd0 . trace ;
568
565
var stash = cd0 . t ;
@@ -610,11 +607,9 @@ function plot(gd, subplot, cdata) {
610
607
}
611
608
}
612
609
613
-
614
610
if ( selectMode ) {
615
- // create select2d
611
+ // create scatter instance by cloning scatter2d
616
612
if ( ! scene . select2d ) {
617
- // create scatter instance by cloning scatter2d
618
613
scene . select2d = createScatter ( fullLayout . _glcanvas . data ( ) [ 1 ] . regl ) ;
619
614
}
620
615
@@ -639,9 +634,9 @@ function plot(gd, subplot, cdata) {
639
634
} ) ;
640
635
}
641
636
} else {
637
+ // reset 'context' scatter2d opts to base opts,
638
+ // thus unsetting markerUnselectedOptions from selection
642
639
if ( scene . scatter2d ) {
643
- // reset scatter2d opts to base opts,
644
- // thus unsetting markerUnselectedOptions from selection
645
640
scene . scatter2d . update ( scene . markerOptions ) ;
646
641
}
647
642
}
@@ -680,7 +675,6 @@ function plot(gd, subplot, cdata) {
680
675
}
681
676
}
682
677
683
-
684
678
function hoverPoints ( pointData , xval , yval , hovermode ) {
685
679
var cd = pointData . cd ;
686
680
var stash = cd [ 0 ] . t ;
@@ -758,7 +752,6 @@ function hoverPoints(pointData, xval, yval, hovermode) {
758
752
return [ pointData ] ;
759
753
}
760
754
761
-
762
755
function calcHover ( pointData , x , y , trace ) {
763
756
var xa = pointData . xa ;
764
757
var ya = pointData . ya ;
@@ -924,7 +917,6 @@ function selectPoints(searchInfo, selectionTester) {
924
917
scene . selectBatch [ stash . index ] = els ;
925
918
scene . unselectBatch [ stash . index ] = unels ;
926
919
927
- // update text options
928
920
if ( hasText ) {
929
921
styleTextSelection ( cd ) ;
930
922
}
0 commit comments