@@ -49,6 +49,31 @@ describe('filter transforms defaults:', function() {
4949 enabled : false ,
5050 } ] ) ;
5151 } ) ;
52+
53+ it ( 'supplyTraceDefaults should coerce *filtersrc* as a strict / noBlank string' , function ( ) {
54+ traceIn = {
55+ x : [ 1 , 2 , 3 ] ,
56+ transforms : [ {
57+ type : 'filter' ,
58+ } , {
59+ type : 'filter' ,
60+ filtersrc : 0
61+ } , {
62+ type : 'filter' ,
63+ filtersrc : ''
64+ } , {
65+ type : 'filter' ,
66+ filtersrc : 'marker.color'
67+ } ]
68+ } ;
69+
70+ traceOut = Plots . supplyTraceDefaults ( traceIn , 0 , { } ) ;
71+
72+ expect ( traceOut . transforms [ 0 ] . filtersrc ) . toEqual ( 'x' ) ;
73+ expect ( traceOut . transforms [ 1 ] . filtersrc ) . toEqual ( 'x' ) ;
74+ expect ( traceOut . transforms [ 2 ] . filtersrc ) . toEqual ( 'x' ) ;
75+ expect ( traceOut . transforms [ 3 ] . filtersrc ) . toEqual ( 'marker.color' ) ;
76+ } ) ;
5277} ) ;
5378
5479describe ( 'filter transforms calc:' , function ( ) {
@@ -95,6 +120,55 @@ describe('filter transforms calc:', function() {
95120 expect ( out [ 0 ] . y ) . toEqual ( base . y ) ;
96121 } ) ;
97122
123+ it ( 'filters should handle geographical *lon* data' , function ( ) {
124+ var trace0 = {
125+ type : 'scattergeo' ,
126+ lon : [ - 90 , - 40 , 100 , 120 , 130 ] ,
127+ lat : [ - 50 , - 40 , 10 , 20 , 30 ] ,
128+ transforms : [ {
129+ type : 'filter' ,
130+ operation : '>' ,
131+ value : 0 ,
132+ filtersrc : 'lon'
133+ } ]
134+ } ;
135+
136+ var trace1 = {
137+ type : 'scattermapbox' ,
138+ lon : [ - 90 , - 40 , 100 , 120 , 130 ] ,
139+ lat : [ - 50 , - 40 , 10 , 20 , 30 ] ,
140+ transforms : [ {
141+ type : 'filter' ,
142+ operation : '<' ,
143+ value : 0 ,
144+ filtersrc : 'lat'
145+ } ]
146+ } ;
147+
148+ var out = _transform ( [ trace0 , trace1 ] ) ;
149+
150+ expect ( out [ 0 ] . lon ) . toEqual ( [ 100 , 120 , 130 ] ) ;
151+ expect ( out [ 0 ] . lat ) . toEqual ( [ 10 , 20 , 30 ] ) ;
152+
153+ expect ( out [ 1 ] . lon ) . toEqual ( [ - 90 , - 40 ] ) ;
154+ expect ( out [ 1 ] . lat ) . toEqual ( [ - 50 , - 40 ] ) ;
155+ } ) ;
156+
157+ it ( 'filters should handle nested attributes' , function ( ) {
158+ var out = _transform ( [ Lib . extendDeep ( { } , base , {
159+ transforms : [ {
160+ type : 'filter' ,
161+ operation : '>' ,
162+ value : 0.2 ,
163+ filtersrc : 'marker.color'
164+ } ]
165+ } ) ] ) ;
166+
167+ expect ( out [ 0 ] . x ) . toEqual ( [ - 2 , 2 , 3 ] ) ;
168+ expect ( out [ 0 ] . y ) . toEqual ( [ 3 , 3 , 1 ] ) ;
169+ expect ( out [ 0 ] . marker . color ) . toEqual ( [ 0.3 , 0.3 , 0.4 ] ) ;
170+ } ) ;
171+
98172 it ( 'filters should skip if *enabled* is false' , function ( ) {
99173 var out = _transform ( [ Lib . extendDeep ( { } , base , {
100174 transforms : [ {
0 commit comments