@@ -615,6 +615,14 @@ function plot(gd, subplot, cdata) {
615615 scene . select2d . update ( scene . markerOptions ) ;
616616 scene . select2d . update ( scene . markerSelectedOptions ) ;
617617 }
618+
619+ if ( scene . glText ) {
620+ cdata . forEach ( function ( cdscatter ) {
621+ if ( cdscatter && cdscatter [ 0 ] && cdscatter [ 0 ] . trace ) {
622+ styleTextSelection ( cdscatter ) ;
623+ }
624+ } ) ;
625+ }
618626 }
619627
620628 // upload viewport/range data to GPU
@@ -882,38 +890,17 @@ function selectPoints(searchInfo, polygon) {
882890 }
883891 }
884892
893+ scene . selectBatch [ stash . index ] = els ;
894+ scene . unselectBatch [ stash . index ] = unels ;
895+
885896 // update text options
886897 if ( hasText ) {
887- var baseOpts = scene . textOptions [ stash . index ] ;
888- var selOpts = scene . textSelectedOptions [ stash . index ] || { } ;
889- var unselOpts = scene . textUnselectedOptions [ stash . index ] || { } ;
890- var opts = Lib . extendFlat ( { } , baseOpts ) ;
891-
892- if ( els && unels ) {
893- var stc = selOpts . color ;
894- var utc = unselOpts . color ;
895- var base = baseOpts . color ;
896- opts . color = new Array ( stash . count ) ;
897-
898- for ( i = 0 ; i < els . length ; i ++ ) {
899- opts . color [ els [ i ] ] = stc || base ;
900- }
901- for ( i = 0 ; i < unels . length ; i ++ ) {
902- opts . color [ unels [ i ] ] = utc ? utc :
903- stc ? base : Color . addOpacity ( base , DESELECTDIM ) ;
904- }
905- }
906-
907- scene . glText [ stash . index ] . update ( opts ) ;
898+ styleTextSelection ( cd ) ;
908899 }
909900
910- scene . selectBatch [ stash . index ] = els ;
911- scene . unselectBatch [ stash . index ] = unels ;
912-
913901 return selection ;
914902}
915903
916-
917904function style ( gd , cds ) {
918905 if ( ! cds ) return ;
919906
@@ -929,6 +916,36 @@ function style(gd, cds) {
929916 scene . draw ( ) ;
930917}
931918
919+ function styleTextSelection ( cd ) {
920+ var cd0 = cd [ 0 ] ;
921+ var stash = cd0 . t ;
922+ var scene = stash . _scene ;
923+ var index = stash . index ;
924+ var els = scene . selectBatch [ index ] ;
925+ var unels = scene . unselectBatch [ index ] ;
926+ var baseOpts = scene . textOptions [ index ] ;
927+ var selOpts = scene . textSelectedOptions [ index ] || { } ;
928+ var unselOpts = scene . textUnselectedOptions [ index ] || { } ;
929+ var opts = Lib . extendFlat ( { } , baseOpts ) ;
930+ var i ;
931+
932+ if ( els && unels ) {
933+ var stc = selOpts . color ;
934+ var utc = unselOpts . color ;
935+ var base = baseOpts . color ;
936+ opts . color = new Array ( stash . count ) ;
937+
938+ for ( i = 0 ; i < els . length ; i ++ ) {
939+ opts . color [ els [ i ] ] = stc || base ;
940+ }
941+ for ( i = 0 ; i < unels . length ; i ++ ) {
942+ opts . color [ unels [ i ] ] = utc ? utc :
943+ stc ? base : Color . addOpacity ( base , DESELECTDIM ) ;
944+ }
945+ }
946+
947+ scene . glText [ index ] . update ( opts ) ;
948+ }
932949
933950module . exports = {
934951 moduleType : 'trace' ,
0 commit comments