@@ -15,6 +15,7 @@ describe('aggregate', function() {
15
15
Plotly . newPlot ( gd , [ {
16
16
x : [ 1 , 2 , 3 , 4 , 'fail' ] ,
17
17
y : [ 1.1 , 2.2 , 3.3 , 'nope' , 5.5 ] ,
18
+ customdata : [ 4 , 'nope' , 3 , 2 , 1 ] ,
18
19
marker : {
19
20
size : [ '2001-01-01' , 0.2 , 0.1 , 0.4 , 0.5 ] ,
20
21
color : [ 2 , 4 , '' , 10 , 8 ] ,
@@ -34,6 +35,7 @@ describe('aggregate', function() {
34
35
{ target : 'x' , func : 'sum' } ,
35
36
// non-numerics will not count toward numerator or denominator for avg
36
37
{ target : 'y' , func : 'avg' } ,
38
+ { target : 'customdata' , func : 'change' } ,
37
39
{ target : 'marker.size' , func : 'min' } ,
38
40
{ target : 'marker.color' , func : 'max' } ,
39
41
// marker.opacity doesn't have an entry, but it will default to first
@@ -54,6 +56,7 @@ describe('aggregate', function() {
54
56
55
57
expect ( traceOut . x ) . toEqual ( [ 8 , 2 ] ) ;
56
58
expect ( traceOut . y ) . toBeCloseToArray ( [ 3.3 , 2.2 ] , 5 ) ;
59
+ expect ( traceOut . customdata ) . toEqual ( [ - 3 , undefined ] ) ;
57
60
expect ( traceOut . marker . size ) . toEqual ( [ 0.1 , 0.2 ] ) ;
58
61
expect ( traceOut . marker . color ) . toEqual ( [ 10 , 4 ] ) ;
59
62
expect ( traceOut . marker . opacity ) . toEqual ( [ 0.6 , 'boo' ] ) ;
@@ -221,15 +224,17 @@ describe('aggregate', function() {
221
224
expect ( inverseMapping ) . toEqual ( { 0 : [ 0 , 1 , 4 ] , 1 : [ 2 , 3 ] } ) ;
222
225
} ) ;
223
226
224
- it ( 'handles median, mode, rms, & stddev for numeric data' , function ( ) {
227
+ it ( 'handles median, mode, rms, stddev, change & range for numeric data' , function ( ) {
225
228
// again, nothing is going to barf with non-numeric data, but sometimes it
226
229
// won't make much sense.
227
230
228
231
Plotly . newPlot ( gd , [ {
229
232
x : [ 1 , 1 , 2 , 2 , 1 ] ,
230
233
y : [ 1 , 2 , 3 , 4 , 5 ] ,
234
+ customdata : [ 5 , 4 , 3 , 2 , 1 ] ,
231
235
marker : {
232
236
size : [ 1 , 2 , 3 , 4 , 5 ] ,
237
+ opacity : [ 0.6 , 0.5 , 0.2 , 0.8 , 1.0 ] ,
233
238
line : { width : [ 1 , 1 , 2 , 2 , 1 ] } ,
234
239
color : [ 1 , 1 , 2 , 2 , 1 ]
235
240
} ,
@@ -239,7 +244,9 @@ describe('aggregate', function() {
239
244
aggregations : [
240
245
{ target : 'x' , func : 'mode' } ,
241
246
{ target : 'y' , func : 'median' } ,
247
+ { target : 'customdata' , func : 'change' } ,
242
248
{ target : 'marker.size' , func : 'rms' } ,
249
+ { target : 'marker.opacity' , func : 'range' } ,
243
250
{ target : 'marker.line.width' , func : 'stddev' , funcmode : 'population' } ,
244
251
{ target : 'marker.color' , func : 'stddev' }
245
252
]
@@ -252,7 +259,9 @@ describe('aggregate', function() {
252
259
// but 2 gets to that count first
253
260
expect ( traceOut . x ) . toEqual ( [ 2 , 1 ] ) ;
254
261
expect ( traceOut . y ) . toBeCloseToArray ( [ 3.5 , 2 ] , 5 ) ;
262
+ expect ( traceOut . customdata ) . toEqual ( [ - 4 , 0 ] ) ;
255
263
expect ( traceOut . marker . size ) . toBeCloseToArray ( [ Math . sqrt ( 51 / 4 ) , 2 ] , 5 ) ;
264
+ expect ( traceOut . marker . opacity ) . toEqual ( [ 0.8 , 0 ] ) ;
256
265
expect ( traceOut . marker . line . width ) . toBeCloseToArray ( [ 0.5 , 0 ] , 5 ) ;
257
266
expect ( traceOut . marker . color ) . toBeCloseToArray ( [ Math . sqrt ( 1 / 3 ) , 0 ] , 5 ) ;
258
267
} ) ;
0 commit comments