diff --git a/lib/alter.js b/lib/alter.js index 17bc3e60f520a..43b14335cd9b6 100644 --- a/lib/alter.js +++ b/lib/alter.js @@ -4,7 +4,7 @@ var _ = require('lodash'); /* @param {Array} args * - args[0] must be a seriesList - * @params {Function} fn - Function used to combine points at same index in each array of each series in the seriesList. + * @params {Function} fn - Function to apply to each series in the seriesList * @return {seriesList} */ diff --git a/series_functions/abs.js b/series_functions/abs.js index 90cb9334e9033..e05fc0dcd0087 100644 --- a/series_functions/abs.js +++ b/series_functions/abs.js @@ -10,12 +10,12 @@ module.exports = new Chainable('abs', { ], help: 'Return the absolute value of each value in the series list', fn: function absFn(args) { - return alter(args, function (inputSeries) { - var data = _.map(inputSeries.data, function (point) { + return alter(args, function (eachSeries) { + var data = _.map(eachSeries.data, function (point) { return [point[0], Math.abs(point[1])]; }); - inputSeries.data = data; - return inputSeries; + eachSeries.data = data; + return eachSeries; }); } }); diff --git a/series_functions/bars.js b/series_functions/bars.js index bdf6e94c61667..a5aa884d6ed71 100644 --- a/series_functions/bars.js +++ b/series_functions/bars.js @@ -13,11 +13,11 @@ module.exports = new Chainable('bars', { ], help: 'Show the seriesList as bars', fn: function barsFn(args) { - return alter(args, function (inputSeries, width) { - inputSeries.bars = inputSeries.bars || {}; - inputSeries.bars.show = width == null ? 1 : width; - inputSeries.bars.lineWidth = width == null ? 6 : width; - return inputSeries; + return alter(args, function (eachSeries, width) { + eachSeries.bars = eachSeries.bars || {}; + eachSeries.bars.show = width == null ? 1 : width; + eachSeries.bars.lineWidth = width == null ? 6 : width; + return eachSeries; }); } }); diff --git a/series_functions/color.js b/series_functions/color.js index 8404b0a7ce5c4..1bd955e34ab8a 100644 --- a/series_functions/color.js +++ b/series_functions/color.js @@ -13,9 +13,9 @@ module.exports = new Chainable('color', { ], help: 'Change the color of the series', fn: function colorFn(args) { - return alter(args, function (inputSeries, color) { - inputSeries.color = color; - return inputSeries; + return alter(args, function (eachSeries, color) { + eachSeries.color = color; + return eachSeries; }); } }); diff --git a/series_functions/derivative.js b/series_functions/derivative.js index d626163d382ce..ae655322e51d7 100644 --- a/series_functions/derivative.js +++ b/series_functions/derivative.js @@ -10,14 +10,14 @@ module.exports = new Chainable('derivative', { ], help: 'Show the seriesList as bars', fn: function derivativeFn(args) { - return alter(args, function (inputSeries) { - var pairs = inputSeries.data; - inputSeries.data = _.map(pairs, function (point, i) { + return alter(args, function (eachSeries) { + var pairs = eachSeries.data; + eachSeries.data = _.map(pairs, function (point, i) { if (i === 0 || pairs[i - 1][1] == null || point[1] == null) { return [point[0], null]; } return [point[0], point[1] - pairs[i - 1][1]]; }); - return inputSeries; + return eachSeries; }); } }); diff --git a/series_functions/first.js b/series_functions/first.js index 947b36c7d05d6..3569376f1e18d 100644 --- a/series_functions/first.js +++ b/series_functions/first.js @@ -9,8 +9,8 @@ module.exports = new Chainable('first', { ], help: 'This is an internal function that simply returns the input series. Don\'t use this', fn: function firstFn(args) { - return alter(args, function (inputSeries) { - return inputSeries; + return alter(args, function (eachSeries) { + return eachSeries; }); } }); \ No newline at end of file diff --git a/series_functions/hide.js b/series_functions/hide.js index a00e283f7ae2b..242373ec4e678 100644 --- a/series_functions/hide.js +++ b/series_functions/hide.js @@ -13,9 +13,9 @@ module.exports = new Chainable('hide', { ], help: 'Hide the series by default', fn: function hideFn(args) { - return alter(args, function (inputSeries, hide) { - inputSeries._hide = hide == null ? true : hide; - return inputSeries; + return alter(args, function (eachSeries, hide) { + eachSeries._hide = hide == null ? true : hide; + return eachSeries; }); } }); diff --git a/series_functions/label.js b/series_functions/label.js index 5608fd40c2f8b..cf279b136fd6f 100644 --- a/series_functions/label.js +++ b/series_functions/label.js @@ -15,14 +15,14 @@ module.exports = new Chainable('label', { ], help: 'Change the label of the series. Use %s reference the existing label', fn: function labelFn(args) { - return alter(args, function (inputSeries, label) { + return alter(args, function (eachSeries, label) { if (label.indexOf('%s') !== -1) { - inputSeries.label = util.format(label, inputSeries.label); + eachSeries.label = util.format(label, eachSeries.label); } else { - inputSeries.label = label; + eachSeries.label = label; } - return inputSeries; + return eachSeries; }); } }); diff --git a/series_functions/legend.js b/series_functions/legend.js index b89b5a9079205..ca53aa34039fa 100644 --- a/series_functions/legend.js +++ b/series_functions/legend.js @@ -18,13 +18,13 @@ module.exports = new Chainable('legend', { ], help: 'Set the position and style of the legend on the plot', fn: function yaxisFn(args) { - return alter(args, function (inputSeries, position, columns) { - inputSeries._global = inputSeries._global || {}; - inputSeries._global.legend = inputSeries._global.legend || {}; - inputSeries._global.legend.position = position; - inputSeries._global.legend.noColumns = columns; + return alter(args, function (eachSeries, position, columns) { + eachSeries._global = eachSeries._global || {}; + eachSeries._global.legend = eachSeries._global.legend || {}; + eachSeries._global.legend.position = position; + eachSeries._global.legend.noColumns = columns; - return inputSeries; + return eachSeries; }); } }); diff --git a/series_functions/lines.js b/series_functions/lines.js index 17aef27039b56..18434f8c20fb9 100644 --- a/series_functions/lines.js +++ b/series_functions/lines.js @@ -26,18 +26,18 @@ module.exports = new Chainable('lines', { ], help: 'Show the seriesList as lines', fn: function linesFn(args) { - return alter(args, function (inputSeries, width, fill, show, steps) { - inputSeries.lines = inputSeries.lines || {}; + return alter(args, function (eachSeries, width, fill, show, steps) { + eachSeries.lines = eachSeries.lines || {}; // Defaults - if (inputSeries.lines.lineWidth == null) inputSeries.lines.lineWidth = 3; + if (eachSeries.lines.lineWidth == null) eachSeries.lines.lineWidth = 3; - if (width != null) inputSeries.lines.lineWidth = width; - if (fill != null) inputSeries.lines.fill = fill / 10; - if (show != null) inputSeries.lines.show = show; - if (steps != null) inputSeries.lines.steps = steps; + if (width != null) eachSeries.lines.lineWidth = width; + if (fill != null) eachSeries.lines.fill = fill / 10; + if (show != null) eachSeries.lines.show = show; + if (steps != null) eachSeries.lines.steps = steps; - return inputSeries; + return eachSeries; }); } }); diff --git a/series_functions/movingaverage.js b/series_functions/movingaverage.js index 0fb316ed35ea0..8ae057c3ed5ec 100644 --- a/series_functions/movingaverage.js +++ b/series_functions/movingaverage.js @@ -15,11 +15,11 @@ module.exports = new Chainable('movingaverage', { aliases: ['mvavg'], help: 'Calculate the moving average over a given window. Nice for smoothing noisey series', fn: function movingaverageFn(args) { - return alter(args, function (inputSeries, _window) { + return alter(args, function (eachSeries, _window) { - var pairs = inputSeries.data; + var pairs = eachSeries.data; - inputSeries.data = _.map(pairs, function (point, i) { + eachSeries.data = _.map(pairs, function (point, i) { if (i < _window) { return [point[0], null]; } var average = _.chain(pairs.slice(i - _window, i)) @@ -31,7 +31,7 @@ module.exports = new Chainable('movingaverage', { return [point[0], average]; }); - return inputSeries; + return eachSeries; }); } }); diff --git a/series_functions/points.js b/series_functions/points.js index 2ed7635cef0af..b51d4e9db8812 100644 --- a/series_functions/points.js +++ b/series_functions/points.js @@ -30,27 +30,27 @@ module.exports = new Chainable('points', { ], help: 'Show the series as points', fn: function pointsFn(args) { - return alter(args, function (inputSeries, radius, weight, fill, fillColor, show) { - inputSeries.points = inputSeries.points || {}; - inputSeries.points.radius = radius == null ? undefined : radius; + return alter(args, function (eachSeries, radius, weight, fill, fillColor, show) { + eachSeries.points = eachSeries.points || {}; + eachSeries.points.radius = radius == null ? undefined : radius; if (fill) { - inputSeries.points.fillColor = fillColor == null ? false : fillColor; + eachSeries.points.fillColor = fillColor == null ? false : fillColor; } if (fill != null) { - inputSeries.points.fill = fill / 10; + eachSeries.points.fill = fill / 10; } if (weight != null) { - inputSeries.points.lineWidth = weight; + eachSeries.points.lineWidth = weight; } - inputSeries.points.show = show == null ? true : show; + eachSeries.points.show = show == null ? true : show; - return inputSeries; + return eachSeries; }); } }); diff --git a/series_functions/worldbank.js b/series_functions/worldbank.js index a5ee6be562349..2a985d131a0ff 100644 --- a/series_functions/worldbank.js +++ b/series_functions/worldbank.js @@ -24,8 +24,6 @@ module.exports = new Datasource ('worldbank', { max: moment(tlConfig.time.to).format('YYYY') }; - console.log(time); - var URL = 'http://api.worldbank.org/' + config.code + '?date=' + time.min + ':' + time.max + '&format=json' + diff --git a/series_functions/yaxis.js b/series_functions/yaxis.js index 7651777672afb..0758504af41e9 100644 --- a/series_functions/yaxis.js +++ b/series_functions/yaxis.js @@ -26,20 +26,20 @@ module.exports = new Chainable('yaxis', { ], help: 'This is an internal function that simply returns the input series. Don\'t use this', fn: function yaxisFn(args) { - return alter(args, function (inputSeries, yaxis, min, max, position) { + return alter(args, function (eachSeries, yaxis, min, max, position) { yaxis = yaxis || 1; - inputSeries.yaxis = yaxis; - inputSeries._global = inputSeries._global || {}; + eachSeries.yaxis = yaxis; + eachSeries._global = eachSeries._global || {}; - var yaxes = inputSeries._global.yaxes = inputSeries._global.yaxes || []; + var yaxes = eachSeries._global.yaxes = eachSeries._global.yaxes || []; var myAxis = yaxes[yaxis - 1] = yaxes[yaxis - 1] || {}; myAxis.position = position; myAxis.min = min == null ? 0 : min; myAxis.max = max; - return inputSeries; + return eachSeries; }); } });