@@ -962,6 +962,72 @@ describe('@gl Test gl2d plots', function() {
962962 . catch ( failTest )
963963 . then ( done ) ;
964964 } ) ;
965+
966+ it ( 'should handle transform traces properly (calcTransform case)' , function ( done ) {
967+ spyOn ( ScatterGl , 'calc' ) . and . callThrough ( ) ;
968+
969+ Plotly . plot ( gd , [ {
970+ type : 'scattergl' ,
971+ x : [ 1 , 2 , 3 ] ,
972+ y : [ 1 , 2 , 1 ] ,
973+ transforms : [ {
974+ type : 'filter' ,
975+ target : 'x' ,
976+ operation : '>' ,
977+ value : 1
978+ } ]
979+ } ] )
980+ . then ( function ( ) {
981+ expect ( ScatterGl . calc ) . toHaveBeenCalledTimes ( 2 ) ;
982+
983+ var opts = gd . calcdata [ 0 ] [ 0 ] . t . _scene . markerOptions ;
984+ // length === 2 before #2677
985+ expect ( opts . length ) . toBe ( 1 ) ;
986+
987+ return Plotly . restyle ( gd , 'selectedpoints' , [ [ 1 ] ] ) ;
988+ } )
989+ . then ( function ( ) {
990+ // was === 1 before #2677
991+ var scene = gd . calcdata [ 0 ] [ 0 ] . t . _scene ;
992+ expect ( scene . selectBatch [ 0 ] ) . toEqual ( [ 0 ] ) ;
993+ } )
994+ . catch ( failTest )
995+ . then ( done ) ;
996+ } ) ;
997+
998+ it ( 'should handle transform traces properly (default transform case)' , function ( done ) {
999+ spyOn ( ScatterGl , 'calc' ) . and . callThrough ( ) ;
1000+
1001+ Plotly . plot ( gd , [ {
1002+ type : 'scattergl' ,
1003+ x : [ 1 , 2 , 3 ] ,
1004+ y : [ 1 , 2 , 1 ] ,
1005+ transforms : [ {
1006+ type : 'groupby' ,
1007+ groups : [ 'a' , 'b' , 'a' ]
1008+ } ]
1009+ } ] )
1010+ . then ( function ( ) {
1011+ // twice per 'expanded' trace
1012+ expect ( ScatterGl . calc ) . toHaveBeenCalledTimes ( 4 ) ;
1013+
1014+ // 'scene' from opts0 and opts1 is linked to the same object,
1015+ // which has two items, one for each 'expanded' trace
1016+ var opts0 = gd . calcdata [ 0 ] [ 0 ] . t . _scene . markerOptions ;
1017+ expect ( opts0 . length ) . toBe ( 2 ) ;
1018+
1019+ var opts1 = gd . calcdata [ 1 ] [ 0 ] . t . _scene . markerOptions ;
1020+ expect ( opts1 . length ) . toBe ( 2 ) ;
1021+
1022+ return Plotly . restyle ( gd , 'selectedpoints' , [ [ 1 ] ] ) ;
1023+ } )
1024+ . then ( function ( ) {
1025+ var scene = gd . calcdata [ 0 ] [ 0 ] . t . _scene ;
1026+ expect ( scene . selectBatch ) . toEqual ( [ [ ] , [ 0 ] ] ) ;
1027+ } )
1028+ . catch ( failTest )
1029+ . then ( done ) ;
1030+ } ) ;
9651031} ) ;
9661032
9671033describe ( 'Test scattergl autorange:' , function ( ) {
0 commit comments