kibana-123
Version:
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic
30 lines (28 loc) • 782 B
JavaScript
var alter = require('../lib/alter.js');
var _ = require('lodash');
var Chainable = require('../lib/classes/chainable');
module.exports = new Chainable('cusum', {
args: [
{
name: 'inputSeries',
types: ['seriesList']
},
{
name: 'base',
types: ['number'],
help: 'Number to start at. Basically just adds this to the beginning of the series'
}
],
help: 'Return the cumulative sum of a series, starting at a base.',
fn: function cusumFn(args) {
return alter(args, function (eachSeries, base) {
var pairs = eachSeries.data;
var total = base || 0;
eachSeries.data = _.map(pairs, function (point, i) {
total += point[1];
return [point[0], total];
});
return eachSeries;
});
}
});