diff --git a/src/app/controllers/graphiteTarget.js b/src/app/controllers/graphiteTarget.js
index e73e192483b..4314b834bf5 100644
--- a/src/app/controllers/graphiteTarget.js
+++ b/src/app/controllers/graphiteTarget.js
@@ -1,37 +1,13 @@
define([
'angular',
'underscore',
- 'config'
+ 'config',
+ '/app/services/graphite/functions.js'
],
-function (angular, _, config) {
+function (angular, _, config, graphiteFunctions) {
'use strict';
var module = angular.module('kibana.controllers');
- var funcDefs = [
- {
- name: "scaleToSeconds",
- params: [ { name: "seconds", type: "int" } ],
- defaultParams: [1]
- },
- {
- name: "sumSeries",
- params: [],
- },
- {
- name: "groupByNode",
- params: [
- {
- name: "node",
- type: "node",
- },
- {
- name: "function",
- type: "function",
- }
- ],
- defaultParams: [3, "sumSeries"]
- }
- ];
module.controller('GraphiteTargetCtrl', function($scope, $http) {
@@ -43,7 +19,7 @@ function (angular, _, config) {
};
});
- $scope.funcDefs = funcDefs;
+ $scope.funcDefs = graphiteFunctions;
$scope.functions = [];
};
@@ -100,6 +76,19 @@ function (angular, _, config) {
return text;
}
+ function wrapFunction(target, func) {
+ var targetWrapped = func.def.name + '(' + target;
+ _.each(func.params, function(param) {
+ if (_.isString(param)) {
+ targetWrapped += ",'" + param + "'";
+ }
+ else {
+ targetWrapped += "," + param;
+ }
+ });
+ return targetWrapped + ')';
+ }
+
$scope.getAltSegments = function (index) {
$scope.altSegments = [];
@@ -135,16 +124,21 @@ function (angular, _, config) {
};
$scope.targetChanged = function() {
- $scope.target.target = getSegmentPathUpTo($scope.segments.length);
+ var target = getSegmentPathUpTo($scope.segments.length);
+ target = _.reduce($scope.functions, wrapFunction, target);
+ console.log('target: ', target);
+ $scope.target.target = target;
$scope.$parent.get_data();
};
$scope.removeFunction = function(func) {
$scope.functions = _.without($scope.functions, func);
+ $scope.targetChanged();
};
$scope.functionParamsChanged = function(func) {
func.text = getFuncText(func.def, func.params);
+ $scope.targetChanged();
};
$scope.addFunction = function(funcDef) {
@@ -153,6 +147,7 @@ function (angular, _, config) {
params: funcDef.defaultParams,
text: getFuncText(funcDef, funcDef.defaultParams)
});
+ $scope.targetChanged();
};
});
diff --git a/src/app/panels/graphite/funcEditor.html b/src/app/panels/graphite/funcEditor.html
index 145e2530c61..ac7e2a025d4 100644
--- a/src/app/panels/graphite/funcEditor.html
+++ b/src/app/panels/graphite/funcEditor.html
@@ -23,7 +23,7 @@
1) {
- required_times = Array.prototype.concat.apply([], _.map(data, function (query) {
- return query.time_series.getOrderedTimes();
- }));
- required_times = _.uniq(required_times.sort(function (a, b) {
- // decending numeric sort
- return a-b;
- }), true);
- }
-
- for (var i = 0; i < data.length; i++) {
- var _d = data[i].time_series.getFlotPairs(required_times);
- data[i].data = _d;
- }
-
- /* var totalDataPoints = _.reduce(data, function(num, series) { return series.data.length + num; }, 0);
- console.log('Datapoints[0] count:', data[0].data.length);
- console.log('Datapoints.Total count:', totalDataPoints);*/
-
- plot = $.plot(elem, data, options);
-
- if (scope.panel.leftYAxisLabel) {
- elem.css('margin-left', '10px');
- var yaxisLabel = $("
")
- .text(scope.panel.leftYAxisLabel)
- .appendTo(elem);
-
- yaxisLabel.css("margin-top", yaxisLabel.width() / 2 - 20);
- } else if (elem.css('margin-left')) {
- elem.css('margin-left', '');
- }
-
- } catch(e) {
- console.log(e);
- // Nothing to do here
+ }
+ //xaxis: int // the x axis to attach events to
+ };
}
+
+ if(scope.panel.interactive) {
+ options.selection = { mode: "x", color: '#666' };
+ }
+
+ // when rendering stacked bars, we need to ensure each point that has data is zero-filled
+ // so that the stacking happens in the proper order
+ var required_times = [];
+ if (data.length > 1) {
+ required_times = Array.prototype.concat.apply([], _.map(data, function (query) {
+ return query.time_series.getOrderedTimes();
+ }));
+ required_times = _.uniq(required_times.sort(function (a, b) {
+ // decending numeric sort
+ return a-b;
+ }), true);
+ }
+
+ for (var i = 0; i < data.length; i++) {
+ var _d = data[i].time_series.getFlotPairs(required_times);
+ data[i].data = _d;
+ }
+
+ /* var totalDataPoints = _.reduce(data, function(num, series) { return series.data.length + num; }, 0);
+ console.log('Datapoints[0] count:', data[0].data.length);
+ console.log('Datapoints.Total count:', totalDataPoints);*/
+
+ plot = $.plot(elem, data, options);
+
+ if (scope.panel.leftYAxisLabel) {
+ elem.css('margin-left', '10px');
+ var yaxisLabel = $("
")
+ .text(scope.panel.leftYAxisLabel)
+ .appendTo(elem);
+
+ yaxisLabel.css("margin-top", yaxisLabel.width() / 2 - 20);
+ } else if (elem.css('margin-left')) {
+ elem.css('margin-left', '');
+ }
+
}
function time_format(interval) {
diff --git a/src/app/services/graphite/functions.js b/src/app/services/graphite/functions.js
new file mode 100644
index 00000000000..09ea8d66bf5
--- /dev/null
+++ b/src/app/services/graphite/functions.js
@@ -0,0 +1,44 @@
+define([
+],
+function () {
+ 'use strict';
+
+ return [
+ {
+ name: "scaleToSeconds",
+ params: [ { name: "seconds", type: "int" } ],
+ defaultParams: [1]
+ },
+ {
+ name: "sumSeries",
+ params: [],
+ },
+ {
+ name: "groupByNode",
+ params: [
+ {
+ name: "node",
+ type: "node",
+ },
+ {
+ name: "function",
+ type: "function",
+ }
+ ],
+ defaultParams: [3, "sumSeries"]
+ },
+ {
+ name: "alias",
+ params: [
+ { name: "alias", type: 'string' }
+ ],
+ defaultParams: ['alias']
+ },
+ {
+ name: 'aliasByNode',
+ params: [ { name: "node", type: "node", } ],
+ defaultParams: [3]
+ }
+ ];
+
+});
\ No newline at end of file
diff --git a/src/app/services/graphite/graphiteSrv.js b/src/app/services/graphite/graphiteSrv.js
new file mode 100644
index 00000000000..682e5ea11f4
--- /dev/null
+++ b/src/app/services/graphite/graphiteSrv.js
@@ -0,0 +1,7 @@
+define([
+],
+function () {
+
+
+
+});
\ No newline at end of file