PR for request #562
https://github.com/alexanderzobnin/grafana-zabbix/issues/562
This commit is contained in:
60
dist/datasource-zabbix/timeseries.js
vendored
60
dist/datasource-zabbix/timeseries.js
vendored
@@ -5,8 +5,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
|
||||
var _, utils, POINT_VALUE, POINT_TIMESTAMP, exportedFunctions;
|
||||
|
||||
/**
|
||||
* Downsample time series by using given function (avg, min, max).
|
||||
/**
|
||||
* Downsample time series by using given function (avg, min, max).
|
||||
*/
|
||||
function downsample(datapoints, time_to, ms_interval, func) {
|
||||
var downsampledSeries = [];
|
||||
@@ -54,9 +54,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return downsampledSeries.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Group points by given time interval
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
/**
|
||||
* Group points by given time interval
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
*/
|
||||
function groupBy(datapoints, interval, groupByCallback) {
|
||||
var ms_interval = utils.parseInterval(interval);
|
||||
@@ -120,9 +120,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return grouped_series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize set of time series into one.
|
||||
* @param {datapoints[]} timeseries array of time series
|
||||
/**
|
||||
* Summarize set of time series into one.
|
||||
* @param {datapoints[]} timeseries array of time series
|
||||
*/
|
||||
function sumSeries(timeseries) {
|
||||
|
||||
@@ -173,9 +173,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return datapoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple delta. Calculate value delta between points.
|
||||
* @param {*} datapoints
|
||||
/**
|
||||
* Simple delta. Calculate value delta between points.
|
||||
* @param {*} datapoints
|
||||
*/
|
||||
function delta(datapoints) {
|
||||
var newSeries = [];
|
||||
@@ -187,9 +187,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return newSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates rate per second. Resistant to counter reset.
|
||||
* @param {*} datapoints
|
||||
/**
|
||||
* Calculates rate per second. Resistant to counter reset.
|
||||
* @param {*} datapoints
|
||||
*/
|
||||
function rate(datapoints) {
|
||||
var newSeries = [];
|
||||
@@ -359,13 +359,13 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
// Utility functions //
|
||||
///////////////////////
|
||||
|
||||
/**
|
||||
* For given point calculate corresponding time frame.
|
||||
*
|
||||
* |__*_|_*__|___*| -> |*___|*___|*___|
|
||||
*
|
||||
* @param {*} timestamp
|
||||
* @param {*} ms_interval
|
||||
/**
|
||||
* For given point calculate corresponding time frame.
|
||||
*
|
||||
* |__*_|_*__|___*| -> |*___|*___|*___|
|
||||
*
|
||||
* @param {*} timestamp
|
||||
* @param {*} ms_interval
|
||||
*/
|
||||
function getPointTimeFrame(timestamp, ms_interval) {
|
||||
return Math.floor(timestamp / ms_interval) * ms_interval;
|
||||
@@ -377,13 +377,13 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill empty front and end of series by zeroes.
|
||||
*
|
||||
* | *** | | *** |
|
||||
* |___ ___| -> |*** ***|
|
||||
* @param {*} series
|
||||
* @param {*} timestamps
|
||||
/**
|
||||
* Fill empty front and end of series by zeroes.
|
||||
*
|
||||
* | *** | | *** |
|
||||
* |___ ___| -> |*** ***|
|
||||
* @param {*} series
|
||||
* @param {*} timestamps
|
||||
*/
|
||||
function fillZeroes(series, timestamps) {
|
||||
var prepend = [];
|
||||
@@ -401,8 +401,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return _.concat(_.concat(prepend, series), append);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate series with gaps
|
||||
/**
|
||||
* Interpolate series with gaps
|
||||
*/
|
||||
function interpolateSeries(series) {
|
||||
var left, right;
|
||||
|
||||
Reference in New Issue
Block a user