@@ -68,7 +68,7 @@ var attrs = exports.attributes = {
68
68
} ,
69
69
func : {
70
70
valType : 'enumerated' ,
71
- values : [ 'count' , 'sum' , 'avg' , 'median' , 'mode' , 'rms' , 'stddev' , 'min' , 'max' , 'first' , 'last' ] ,
71
+ values : [ 'count' , 'sum' , 'avg' , 'median' , 'mode' , 'rms' , 'stddev' , 'min' , 'max' , 'first' , 'last' , 'change' ] ,
72
72
dflt : 'first' ,
73
73
role : 'info' ,
74
74
editType : 'calc' ,
@@ -86,7 +86,8 @@ var attrs = exports.attributes = {
86
86
'for example a sum of dates or average of categories.' ,
87
87
'*median* will return the average of the two central values if there is' ,
88
88
'an even count. *mode* will return the first value to reach the maximum' ,
89
- 'count, in case of a tie.'
89
+ 'count, in case of a tie.' ,
90
+ '*change* will return the difference between the first and last linked value.'
90
91
] . join ( ' ' )
91
92
} ,
92
93
funcmode : {
@@ -297,6 +298,8 @@ function getAggregateFunction(opts, conversions) {
297
298
return first ;
298
299
case 'last' :
299
300
return last ;
301
+ case 'change' :
302
+ return change ;
300
303
301
304
case 'sum' :
302
305
// This will produce output in all cases even though it's nonsensical
@@ -441,3 +444,7 @@ function first(array, indices) {
441
444
function last ( array , indices ) {
442
445
return array [ indices [ indices . length - 1 ] ] ;
443
446
}
447
+
448
+ function change ( array , indices ) {
449
+ return last ( array , indices ) - first ( array , indices ) ;
450
+ }
0 commit comments