Implement movingAverage
This commit is contained in:
@@ -62,6 +62,7 @@ func init() {
|
||||
"offset": applyOffset,
|
||||
"delta": applyDelta,
|
||||
"rate": applyRate,
|
||||
"movingAverage": applyMovingAverage,
|
||||
"removeAboveValue": applyRemoveAboveValue,
|
||||
"removeBelowValue": applyRemoveBelowValue,
|
||||
"transformNull": applyTransformNull,
|
||||
@@ -245,6 +246,16 @@ func applyTransformNull(series timeseries.TimeSeries, params ...interface{}) (ti
|
||||
return series.Transform(transformFunc), nil
|
||||
}
|
||||
|
||||
func applyMovingAverage(series timeseries.TimeSeries, params ...interface{}) (timeseries.TimeSeries, error) {
|
||||
nFloat, err := MustFloat64(params[0])
|
||||
if err != nil {
|
||||
return nil, errParsingFunctionParam(err)
|
||||
}
|
||||
n := int(nFloat)
|
||||
|
||||
return series.SimpleMovingAverage(n), nil
|
||||
}
|
||||
|
||||
func applyAggregateBy(series []*timeseries.TimeSeriesData, params ...interface{}) ([]*timeseries.TimeSeriesData, error) {
|
||||
pInterval, err := MustString(params[0])
|
||||
pAgg, err := MustString(params[1])
|
||||
|
||||
Reference in New Issue
Block a user