@@ -727,3 +727,64 @@ describe('restyle applied on transforms:', function() {
727727 } ) ;
728728
729729} ) ;
730+
731+ describe ( 'supplyDefaults with groupby + filter' , function ( ) {
732+ function calcDatatoTrace ( calcTrace ) {
733+ return calcTrace [ 0 ] . trace ;
734+ }
735+
736+ function _transform ( data , layout ) {
737+ var gd = {
738+ data : data ,
739+ layout : layout || { }
740+ } ;
741+
742+ Plots . supplyDefaults ( gd ) ;
743+ Plots . doCalcdata ( gd ) ;
744+
745+ return gd . calcdata . map ( calcDatatoTrace ) ;
746+ }
747+
748+ it ( 'computes the correct data when filter target blank' , function ( ) {
749+ var out = _transform ( [ {
750+ x : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ,
751+ y : [ 4 , 6 , 5 , 7 , 6 , 8 , 9 ] ,
752+ transforms : [ {
753+ type : "filter" ,
754+ operation : "<" ,
755+ value : 6.5
756+ } , {
757+ type : "groupby" ,
758+ groups : [ 1 , 1 , 1 , 2 , 2 , 2 , 2 ]
759+ } ]
760+ } ] ) ;
761+
762+ expect ( out [ 0 ] . x ) . toEqual ( [ 1 , 2 , 3 ] ) ;
763+ expect ( out [ 0 ] . y ) . toEqual ( [ 4 , 6 , 5 ] ) ;
764+
765+ expect ( out [ 1 ] . x ) . toEqual ( [ 4 , 5 , 6 ] ) ;
766+ expect ( out [ 1 ] . y ) . toEqual ( [ 7 , 6 , 8 ] ) ;
767+ } ) ;
768+
769+ it ( 'computes the correct data when filter target present' , function ( ) {
770+ var out = _transform ( [ {
771+ x : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ,
772+ y : [ 4 , 6 , 5 , 7 , 6 , 8 , 9 ] ,
773+ transforms : [ {
774+ type : "filter" ,
775+ target : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ,
776+ operation : "<" ,
777+ value : 6.5
778+ } , {
779+ type : "groupby" ,
780+ groups : [ 1 , 1 , 1 , 2 , 2 , 2 , 2 ]
781+ } ]
782+ } ] ) ;
783+
784+ expect ( out [ 0 ] . x ) . toEqual ( [ 1 , 2 , 3 ] ) ;
785+ expect ( out [ 0 ] . y ) . toEqual ( [ 4 , 6 , 5 ] ) ;
786+
787+ expect ( out [ 1 ] . x ) . toEqual ( [ 4 , 5 , 6 ] ) ;
788+ expect ( out [ 1 ] . y ) . toEqual ( [ 7 , 6 , 8 ] ) ;
789+ } ) ;
790+ } ) ;
0 commit comments