@@ -72,7 +72,7 @@ ScatterRegl.calc = function calc(container, trace) {
72
72
}
73
73
}
74
74
75
- var lineOptions , scatterOptions , errorXOptions , errorYOptions , fillOptions ;
75
+ var lineOptions , markerOptions , errorXOptions , errorYOptions , fillOptions ;
76
76
var hasLines , hasErrorX , hasErrorY , hasError , hasMarkers , hasFill ;
77
77
var linePositions ;
78
78
@@ -292,8 +292,8 @@ ScatterRegl.calc = function calc(container, trace) {
292
292
}
293
293
294
294
if ( hasMarkers ) {
295
- scatterOptions = { } ;
296
- scatterOptions . positions = positions ;
295
+ markerOptions = { } ;
296
+ markerOptions . positions = positions ;
297
297
298
298
// get basic symbol info
299
299
var multiMarker = Array . isArray ( markerOpts . symbol ) ;
@@ -303,8 +303,8 @@ ScatterRegl.calc = function calc(container, trace) {
303
303
}
304
304
// prepare colors
305
305
if ( multiMarker || Array . isArray ( markerOpts . color ) || Array . isArray ( markerOpts . line . color ) || Array . isArray ( markerOpts . line ) ) {
306
- scatterOptions . colors = new Array ( count ) ;
307
- scatterOptions . borderColors = new Array ( count ) ;
306
+ markerOptions . colors = new Array ( count ) ;
307
+ markerOptions . borderColors = new Array ( count ) ;
308
308
309
309
var colors = formatColor ( markerOpts , markerOpts . opacity , count ) ;
310
310
var borderColors = formatColor ( markerOpts . line , markerOpts . opacity , count ) ;
@@ -324,8 +324,8 @@ ScatterRegl.calc = function calc(container, trace) {
324
324
}
325
325
}
326
326
327
- scatterOptions . colors = colors ;
328
- scatterOptions . borderColors = borderColors ;
327
+ markerOptions . colors = colors ;
328
+ markerOptions . borderColors = borderColors ;
329
329
330
330
for ( i = 0 ; i < count ; i ++ ) {
331
331
if ( multiMarker ) {
@@ -339,29 +339,29 @@ ScatterRegl.calc = function calc(container, trace) {
339
339
}
340
340
}
341
341
342
- scatterOptions . opacity = trace . opacity ;
342
+ markerOptions . opacity = trace . opacity ;
343
343
}
344
344
else {
345
- scatterOptions . color = markerOpts . color ;
346
- scatterOptions . borderColor = markerOpts . line . color ;
347
- scatterOptions . opacity = trace . opacity * markerOpts . opacity ;
345
+ markerOptions . color = markerOpts . color ;
346
+ markerOptions . borderColor = markerOpts . line . color ;
347
+ markerOptions . opacity = trace . opacity * markerOpts . opacity ;
348
348
349
349
if ( isOpen ) {
350
- scatterOptions . borderColor = scatterOptions . color . slice ( ) ;
351
- scatterOptions . color = scatterOptions . color . slice ( ) ;
352
- scatterOptions . color [ 3 ] = 0 ;
350
+ markerOptions . borderColor = markerOptions . color . slice ( ) ;
351
+ markerOptions . color = markerOptions . color . slice ( ) ;
352
+ markerOptions . color [ 3 ] = 0 ;
353
353
}
354
354
}
355
355
356
356
// prepare markers
357
357
if ( Array . isArray ( markerOpts . symbol ) ) {
358
- scatterOptions . markers = new Array ( count ) ;
358
+ markerOptions . markers = new Array ( count ) ;
359
359
for ( i = 0 ; i < count ; ++ i ) {
360
- scatterOptions . markers [ i ] = getSymbolSdf ( markerOpts . symbol [ i ] ) ;
360
+ markerOptions . markers [ i ] = getSymbolSdf ( markerOpts . symbol [ i ] ) ;
361
361
}
362
362
}
363
363
else {
364
- scatterOptions . marker = getSymbolSdf ( markerOpts . symbol ) ;
364
+ markerOptions . marker = getSymbolSdf ( markerOpts . symbol ) ;
365
365
}
366
366
367
367
// prepare sizes and expand axes
@@ -371,8 +371,8 @@ ScatterRegl.calc = function calc(container, trace) {
371
371
var size , sizes ;
372
372
373
373
if ( multiSize ) {
374
- sizes = scatterOptions . sizes = new Array ( count ) ;
375
- var borderSizes = scatterOptions . borderSizes = new Array ( count ) ;
374
+ sizes = markerOptions . sizes = new Array ( count ) ;
375
+ var borderSizes = markerOptions . borderSizes = new Array ( count ) ;
376
376
377
377
if ( Array . isArray ( markerOpts . size ) ) {
378
378
for ( i = 0 ; i < count ; ++ i ) {
@@ -403,8 +403,8 @@ ScatterRegl.calc = function calc(container, trace) {
403
403
Axes . expand ( yaxis , stash . rawy , { padded : true , ppad : sizes } ) ;
404
404
}
405
405
else {
406
- size = scatterOptions . size = markerSizeFunc ( markerOpts && markerOpts . size || 10 ) ;
407
- scatterOptions . borderSizes = markerOpts . line . width * 0.5 ;
406
+ size = markerOptions . size = markerSizeFunc ( markerOpts && markerOpts . size || 10 ) ;
407
+ markerOptions . borderSizes = markerOpts . line . width * 0.5 ;
408
408
409
409
// axes bounds
410
410
for ( i = 0 ; i < count ; i ++ ) {
@@ -422,7 +422,7 @@ ScatterRegl.calc = function calc(container, trace) {
422
422
}
423
423
// update axes fast for big number of points
424
424
else {
425
- var pad = scatterOptions . size ;
425
+ var pad = markerOptions . size ;
426
426
if ( xaxis . _min ) {
427
427
xaxis . _min . push ( { val : xbounds [ 0 ] , pad : pad } ) ;
428
428
}
@@ -460,7 +460,7 @@ ScatterRegl.calc = function calc(container, trace) {
460
460
// last used options
461
461
lineOptions : [ ] ,
462
462
fillOptions : [ ] ,
463
- scatterOptions : [ ] ,
463
+ markerOptions : [ ] ,
464
464
errorXOptions : [ ] ,
465
465
errorYOptions : [ ] ,
466
466
@@ -508,12 +508,12 @@ ScatterRegl.calc = function calc(container, trace) {
508
508
scene . select2d . regl . clear ( { color : true } ) ;
509
509
510
510
var batch = Array ( scene . count ) , i , traceId ;
511
- for ( i = 0 ; i < scene . count ; i ++ ) {
512
- batch [ i ] = [ ]
511
+ for ( i = 0 ; i < scene . count ; i ++ ) {
512
+ batch [ i ] = [ ] ;
513
513
}
514
514
515
515
for ( i = 0 ; i < selection . length ; i ++ ) {
516
- var traceId = selection [ i ] . curveNumber || 0 ;
516
+ traceId = selection [ i ] . curveNumber || 0 ;
517
517
batch [ traceId ] . push ( selection [ i ] . pointNumber ) ;
518
518
}
519
519
@@ -536,17 +536,17 @@ ScatterRegl.calc = function calc(container, trace) {
536
536
scene . count = 0 ;
537
537
scene . lineOptions = [ ] ;
538
538
scene . fillOptions = [ ] ;
539
- scene . scatterOptions = [ ] ;
539
+ scene . markerOptions = [ ] ;
540
540
scene . errorXOptions = [ ] ;
541
541
scene . errorYOptions = [ ] ;
542
542
}
543
543
544
544
// save initial batch
545
- scene . lineOptions . push ( lineOptions ) ;
546
- scene . errorXOptions . push ( errorXOptions ) ;
547
- scene . errorYOptions . push ( errorYOptions ) ;
548
- scene . fillOptions . push ( fillOptions ) ;
549
- scene . scatterOptions . push ( scatterOptions ) ;
545
+ scene . lineOptions . push ( hasLines ? lineOptions : null ) ;
546
+ scene . errorXOptions . push ( hasErrorX ? errorXOptions : null ) ;
547
+ scene . errorYOptions . push ( hasErrorY ? errorYOptions : null ) ;
548
+ scene . fillOptions . push ( hasFill ? fillOptions : null ) ;
549
+ scene . markerOptions . push ( hasMarkers ? markerOptions : null ) ;
550
550
scene . count ++ ;
551
551
552
552
// stash scene ref
@@ -597,6 +597,7 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
597
597
if ( ! scene ) return ;
598
598
599
599
var vpSize = layout . _size , width = layout . width , height = layout . height ;
600
+
600
601
var regl = layout . _glcanvas . data ( ) [ 0 ] . regl ;
601
602
602
603
// that is needed for fills
@@ -625,7 +626,7 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
625
626
scene . error2d . update ( errorBatch ) ;
626
627
}
627
628
if ( scene . scatter2d ) {
628
- scene . scatter2d . update ( scene . scatterOptions ) ;
629
+ scene . scatter2d . update ( scene . markerOptions ) ;
629
630
}
630
631
// fill requires linked traces, so we generate it's positions here
631
632
if ( scene . fill2d ) {
@@ -681,14 +682,15 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
681
682
682
683
// make sure selection layer is initialized if we require selection
683
684
var dragmode = layout . dragmode ;
685
+
684
686
if ( dragmode === 'lasso' || dragmode === 'select' ) {
685
687
if ( ! scene . select2d && scene . scatter2d ) {
686
688
var selectRegl = layout . _glcanvas . data ( ) [ 1 ] . regl ;
687
689
688
690
scene . select2d = createScatter ( selectRegl ) ;
689
691
690
692
// TODO: modify options here according to the proposed selection options
691
- scene . select2d . update ( scene . scatterOptions ) ;
693
+ scene . select2d . update ( scene . markerOptions ) ;
692
694
}
693
695
}
694
696
else {
@@ -735,16 +737,16 @@ ScatterRegl.plot = function plot(container, subplot, cdata) {
735
737
736
738
// reset opacities
737
739
if ( scene . scatter2d ) {
738
- scene . scatter2d . update ( scene . scatterOptions . map ( function ( opt ) {
740
+ scene . scatter2d . update ( scene . markerOptions . map ( function ( opt ) {
739
741
return { opacity : opt ? opt . opacity : 1 } ;
740
742
} ) ) ;
741
743
}
742
744
}
743
745
744
- return {
746
+ return trace . visible ? {
745
747
viewport : viewport ,
746
748
range : range
747
- } ;
749
+ } : null ;
748
750
} ) ;
749
751
750
752
// uploat batch data to GPU
@@ -879,7 +881,7 @@ ScatterRegl.hoverPoints = function hover(pointData, xval, yval, hovermode) {
879
881
880
882
var hoverlabel = trace . hoverlabel ;
881
883
882
- if ( hoverlabel ) {
884
+ if ( hoverlabel ) {
883
885
di . hbg = Array . isArray ( hoverlabel . bgcolor ) ? hoverlabel . bgcolor [ id ] : hoverlabel . bgcolor ;
884
886
di . hbc = Array . isArray ( hoverlabel . bordercolor ) ? hoverlabel . bordercolor [ id ] : hoverlabel . bordercolor ;
885
887
di . hts = Array . isArray ( hoverlabel . font . size ) ? hoverlabel . font . size [ id ] : hoverlabel . font . size ;
@@ -888,7 +890,7 @@ ScatterRegl.hoverPoints = function hover(pointData, xval, yval, hovermode) {
888
890
di . hnl = Array . isArray ( hoverlabel . namelength ) ? hoverlabel . namelength [ id ] : hoverlabel . namelength ;
889
891
}
890
892
var hoverinfo = trace . hoverinfo ;
891
- if ( hoverinfo ) {
893
+ if ( hoverinfo ) {
892
894
di . hi = Array . isArray ( hoverinfo ) ? hoverinfo [ id ] : hoverinfo ;
893
895
}
894
896
@@ -939,18 +941,18 @@ ScatterRegl.selectPoints = function select(searchInfo, polygon) {
939
941
// degenerate polygon does not enable selection
940
942
if ( polygon === false || polygon . degenerate ) {
941
943
if ( scene . scatter2d ) {
942
- scene . scatter2d . update ( scene . scatterOptions . map ( function ( opt ) {
944
+ scene . scatter2d . update ( scene . markerOptions . map ( function ( opt ) {
943
945
return { opacity : opt . opacity } ;
944
946
} ) ) ;
945
947
}
946
948
}
947
949
// filter out points by visible scatter ones
948
950
else {
949
- let els = [ ]
951
+ var els = [ ] ;
950
952
951
953
for ( var i = 0 ; i < stash . count ; i ++ ) {
952
954
if ( polygon . contains ( [ stash . xpx [ i ] , stash . ypx [ i ] ] ) ) {
953
- els . push ( i )
955
+ els . push ( i ) ;
954
956
selection . push ( {
955
957
pointNumber : i ,
956
958
x : x [ i ] ,
@@ -961,7 +963,7 @@ ScatterRegl.selectPoints = function select(searchInfo, polygon) {
961
963
962
964
// adjust selection transparency via canvas opacity
963
965
if ( scene . scatter2d ) {
964
- scene . scatter2d . update ( scene . scatterOptions . map ( function ( opt ) {
966
+ scene . scatter2d . update ( scene . markerOptions . map ( function ( opt ) {
965
967
return { opacity : opt . opacity * DESELECTDIM } ;
966
968
} ) ) ;
967
969
}
0 commit comments