Resolved #201 - add scale() function.

This commit is contained in:
Alexander Zobnin
2016-06-19 20:09:59 +03:00
parent 022bc263a4
commit c3da65e237
4 changed files with 36 additions and 5 deletions

View File

@@ -142,6 +142,15 @@ export default class DataProcessor {
return timeseries;
}
static scale(factor, datapoints) {
return _.map(datapoints, point => {
return [
point[0] * factor,
point[1]
];
});
}
static groupByWrapper(interval, groupFunc, datapoints) {
var groupByCallback = DataProcessor.aggregationFunctions[groupFunc];
return DataProcessor.groupBy(interval, groupByCallback, datapoints);
@@ -171,6 +180,7 @@ export default class DataProcessor {
static get metricFunctions() {
return {
groupBy: this.groupByWrapper,
scale: this.scale,
aggregateBy: this.aggregateByWrapper,
average: _.partial(this.aggregateWrapper, this.AVERAGE),
min: _.partial(this.aggregateWrapper, this.MIN),