timeseries.js refactor
This commit is contained in:
10
dist/datasource-zabbix/timeseries.js
vendored
10
dist/datasource-zabbix/timeseries.js
vendored
@@ -12,6 +12,10 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
* timeseries.js
|
||||
*
|
||||
* This module contains functions for working with time series.
|
||||
*
|
||||
* datapoints - array of points where point is [value, timestamp]. In almost all cases (if other wasn't
|
||||
* explicitly said) we assume datapoints are sorted by timestamp.
|
||||
*
|
||||
*/
|
||||
|
||||
function downsample(datapoints, time_to, ms_interval, func) {
|
||||
@@ -64,7 +68,7 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
* Group points by given time interval
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
*/
|
||||
function groupBy(interval, groupByCallback, datapoints) {
|
||||
function groupBy(datapoints, interval, groupByCallback) {
|
||||
var ms_interval = utils.parseInterval(interval);
|
||||
|
||||
// Calculate frame timestamps
|
||||
@@ -90,7 +94,7 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
|
||||
/**
|
||||
* Summarize set of time series into one.
|
||||
* @param {object[]} timeseries
|
||||
* @param {datapoints[]} timeseries array of time series
|
||||
*/
|
||||
function sumSeries(timeseries) {
|
||||
|
||||
@@ -124,7 +128,7 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
}
|
||||
|
||||
return sortByTime(new_timeseries);
|
||||
}function scale(factor, datapoints) {
|
||||
}function scale(datapoints, factor) {
|
||||
return _.map(datapoints, function (point) {
|
||||
return [point[0] * factor, point[1]];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user