Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit a86c6fa

Browse files
authored
Merge pull request #1309 from DeleurApps/cumulative
Added cumulative function
2 parents 33c77bb + ad01107 commit a86c6fa

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/graphite.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ See also:
6161
| consolidateBy(seriesList, func) seriesList | | Stable |
6262
| constantLine | | No |
6363
| countSeries(seriesLists) series | | Stable |
64-
| cumulative | | No |
64+
| cumulative | | Stable |
6565
| currentAbove | | No |
6666
| currentBelow | | No |
6767
| dashed | | No |

expr/func_consolidateby.go

+11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ func NewConsolidateBy() GraphiteFunc {
1616
return &FuncConsolidateBy{}
1717
}
1818

19+
func NewConsolidateByConstructor(by string) func() GraphiteFunc {
20+
return func() GraphiteFunc {
21+
return &FuncConsolidateBy{by: by}
22+
}
23+
}
24+
1925
func (s *FuncConsolidateBy) Signature() ([]Arg, []Arg) {
26+
if s.by != "" {
27+
return []Arg{
28+
ArgSeriesList{val: &s.in},
29+
}, []Arg{ArgSeriesList{}}
30+
}
2031
return []Arg{
2132
ArgSeriesList{val: &s.in},
2233
ArgString{val: &s.by, validator: []Validator{IsConsolFunc}},

expr/funcs.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func init() {
5858
"averageSeries": {NewAggregateConstructor("average", crossSeriesAvg), true},
5959
"consolidateBy": {NewConsolidateBy, true},
6060
"countSeries": {NewCountSeries, true},
61+
"cumulative": {NewConsolidateByConstructor("sum"), true},
6162
"derivative": {NewDerivative, true},
6263
"diffSeries": {NewAggregateConstructor("diff", crossSeriesDiff), true},
6364
"divideSeries": {NewDivideSeries, true},

0 commit comments

Comments
 (0)