timeseries.js refactor

This commit is contained in:
Alexander Zobnin
2017-06-25 19:03:43 +03:00
parent b0da0ffb3e
commit 8562dae998
8 changed files with 42 additions and 24 deletions

View File

@@ -5,8 +5,8 @@ import ts from './timeseries';
let downsampleSeries = ts.downsample;
let groupBy = ts.groupBy;
let sumSeries = ts.sumSeries;
let scale = ts.scale;
let delta = ts.delta;
let scale = (factor, datapoints) => ts.scale(datapoints, factor);
let SUM = ts.SUM;
let COUNT = ts.COUNT;
@@ -63,19 +63,19 @@ function extractText(str, pattern) {
function groupByWrapper(interval, groupFunc, datapoints) {
var groupByCallback = aggregationFunctions[groupFunc];
return groupBy(interval, groupByCallback, datapoints);
return groupBy(datapoints, interval, groupByCallback);
}
function aggregateByWrapper(interval, aggregateFunc, datapoints) {
// Flatten all points in frame and then just use groupBy()
var flattenedPoints = _.flatten(datapoints, true);
var groupByCallback = aggregationFunctions[aggregateFunc];
return groupBy(interval, groupByCallback, flattenedPoints);
return groupBy(flattenedPoints, interval, groupByCallback);
}
function aggregateWrapper(groupByCallback, interval, datapoints) {
var flattenedPoints = _.flatten(datapoints, true);
return groupBy(interval, groupByCallback, flattenedPoints);
return groupBy(flattenedPoints, interval, groupByCallback);
}
function timeShift(interval, range) {