@@ -68,7 +68,7 @@ var attrs = exports.attributes = {
6868 } ,
6969 func : {
7070 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' ] ,
7272 dflt : 'first' ,
7373 role : 'info' ,
7474 editType : 'calc' ,
@@ -86,7 +86,8 @@ var attrs = exports.attributes = {
8686 'for example a sum of dates or average of categories.' ,
8787 '*median* will return the average of the two central values if there is' ,
8888 '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.'
9091 ] . join ( ' ' )
9192 } ,
9293 funcmode : {
@@ -297,6 +298,8 @@ function getAggregateFunction(opts, conversions) {
297298 return first ;
298299 case 'last' :
299300 return last ;
301+ case 'change' :
302+ return change ;
300303
301304 case 'sum' :
302305 // This will produce output in all cases even though it's nonsensical
@@ -441,3 +444,7 @@ function first(array, indices) {
441444function last ( array , indices ) {
442445 return array [ indices [ indices . length - 1 ] ] ;
443446}
447+
448+ function change ( array , indices ) {
449+ return last ( array , indices ) - first ( array , indices ) ;
450+ }
0 commit comments