@@ -120,47 +120,71 @@ describe('dc.scatterPlot', function () {
120
120
} ) ;
121
121
} ) ;
122
122
123
- describe ( 'filtering another dimension' , function ( ) {
124
- var otherDimension ;
123
+ function filteringAnotherDimension ( ) {
124
+ describe ( 'filtering another dimension' , function ( ) {
125
+ var otherDimension ;
125
126
126
- beforeEach ( function ( ) {
127
- otherDimension = data . dimension ( function ( d ) { return [ + d . value , + d . nvalue ] ; } ) ;
128
- var ff = dc . filters . RangedTwoDimensionalFilter ( [ [ 22 , - 3 ] , [ 44 , 2 ] ] ) . isFiltered ;
129
- otherDimension . filterFunction ( ff ) ;
130
- chart . redraw ( ) ;
131
- } ) ;
127
+ beforeEach ( function ( ) {
128
+ otherDimension = data . dimension ( function ( d ) { return [ + d . value , + d . nvalue ] ; } ) ;
129
+ var ff = dc . filters . RangedTwoDimensionalFilter ( [ [ 22 , - 3 ] , [ 44 , 2 ] ] ) . isFiltered ;
130
+ otherDimension . filterFunction ( ff ) ;
131
+ chart . redraw ( ) ;
132
+ } ) ;
132
133
133
- it ( 'should show the included points' , function ( ) {
134
- var shownPoints = symbolsOfRadius ( 10 ) ; // test symbolSize
135
- expect ( shownPoints . length ) . toBe ( 2 ) ;
136
- expect ( shownPoints [ 0 ] . key ) . toEqual ( [ 22 , - 2 ] ) ;
137
- expect ( shownPoints [ 1 ] . key ) . toEqual ( [ 33 , 1 ] ) ;
138
- } ) ;
139
- it ( 'should hide the excluded points' , function ( ) {
140
- var emptyPoints = symbolsOfRadius ( 4 ) ; // test emptySize
141
- expect ( emptyPoints . length ) . toBe ( 7 ) ;
142
- } ) ;
143
- it ( 'should use emptyOpacity for excluded points' , function ( ) {
144
- var translucentPoints = symbolsMatching ( function ( ) {
145
- return + d3 . select ( this ) . attr ( 'opacity' ) === 0.5 ; // emptyOpacity
134
+ it ( 'should show the included points' , function ( ) {
135
+ var shownPoints = symbolsOfRadius ( 10 ) ; // test symbolSize
136
+ expect ( shownPoints . length ) . toBe ( 2 ) ;
137
+ expect ( shownPoints [ 0 ] . key ) . toEqual ( [ 22 , - 2 ] ) ;
138
+ expect ( shownPoints [ 1 ] . key ) . toEqual ( [ 33 , 1 ] ) ;
146
139
} ) ;
147
- expect ( translucentPoints . length ) . toBe ( 7 ) ;
148
- } ) ;
149
- it ( 'should use emptyColor for excluded points' , function ( ) {
150
- var chartreusePoints = symbolsMatching ( function ( ) { // don't try this at home
151
- return / # D F F F 0 0 / i. test ( d3 . select ( this ) . attr ( 'fill' ) ) ; // emptyColor
140
+ it ( 'should hide the excluded points' , function ( ) {
141
+ var emptyPoints = symbolsOfRadius ( 4 ) ; // test emptySize
142
+ expect ( emptyPoints . length ) . toBe ( 7 ) ;
152
143
} ) ;
153
- expect ( chartreusePoints . length ) . toBe ( 7 ) ;
154
- } ) ;
155
- it ( 'should update the titles' , function ( ) {
156
- var titles = chart . selectAll ( 'path.symbol title' ) ;
157
- var expected = [ '22,-2: 1' , '22,10: 0' , '33,1: 2' , '44,-3: 0' , '44,-4: 0' ,
158
- '44,2: 0' , '55,-3: 0' , '55,-5: 0' , '66,-4: 0' ] ;
159
- expect ( titles . size ( ) ) . toBe ( expected . length ) ;
160
- titles . each ( function ( d ) {
161
- expect ( this . textContent ) . toBe ( expected . shift ( ) ) ;
144
+ it ( 'should use emptyOpacity for excluded points' , function ( ) {
145
+ var translucentPoints = symbolsMatching ( function ( ) {
146
+ return + d3 . select ( this ) . attr ( 'opacity' ) === 0.5 ; // emptyOpacity
147
+ } ) ;
148
+ expect ( translucentPoints . length ) . toBe ( 7 ) ;
149
+ } ) ;
150
+ it ( 'should use emptyColor for excluded points' , function ( ) {
151
+ var chartreusePoints = symbolsMatching ( function ( ) { // don't try this at home
152
+ return / # D F F F 0 0 / i. test ( d3 . select ( this ) . attr ( 'fill' ) ) ; // emptyColor
153
+ } ) ;
154
+ expect ( chartreusePoints . length ) . toBe ( 7 ) ;
162
155
} ) ;
156
+ it ( 'should update the titles' , function ( ) {
157
+ var titles = chart . selectAll ( 'path.symbol title' ) ;
158
+ var expected = [ '22,-2: 1' , '22,10: 0' , '33,1: 2' , '44,-3: 0' , '44,-4: 0' ,
159
+ '44,2: 0' , '55,-3: 0' , '55,-5: 0' , '66,-4: 0' ] ;
160
+ expect ( titles . size ( ) ) . toBe ( expected . length ) ;
161
+ titles . each ( function ( d ) {
162
+ expect ( this . textContent ) . toBe ( expected . shift ( ) ) ;
163
+ } ) ;
164
+ } ) ;
165
+ } ) ;
166
+ }
167
+ filteringAnotherDimension ( ) ;
168
+
169
+ function cloneGroup ( group ) {
170
+ return {
171
+ all : function ( ) {
172
+ return group . all ( ) . map ( function ( kv ) {
173
+ return {
174
+ key : kv . key . slice ( 0 ) ,
175
+ value : kv . value
176
+ } ;
177
+ } ) ;
178
+ }
179
+ } ;
180
+ }
181
+ describe ( 'with cloned data' , function ( ) {
182
+ beforeEach ( function ( ) {
183
+ chart . group ( cloneGroup ( group ) )
184
+ . render ( ) ;
163
185
} ) ;
186
+
187
+ filteringAnotherDimension ( ) ;
164
188
} ) ;
165
189
166
190
describe ( 'brushing' , function ( ) {
0 commit comments