From 0af5708837e0afb5ad0fc77c81b92b96b624fadd Mon Sep 17 00:00:00 2001 From: Alvaro del Castillo Date: Mon, 19 Oct 2015 19:45:53 +0200 Subject: [PATCH 01/10] Added labels for metrics aggregations in Kibana. Just activated for Metric vis. First version needing improvements in the params handling. --- .../kibana/public/visualize/editor/agg.html | 28 +++++++++++- .../kibana/public/visualize/editor/agg.js | 43 +++++++++++++++++++ .../public/metric_vis_controller.js | 7 ++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/plugins/kibana/public/visualize/editor/agg.html b/src/plugins/kibana/public/visualize/editor/agg.html index 56b3906d6fdde..0fb45899d99fc 100644 --- a/src/plugins/kibana/public/visualize/editor/agg.html +++ b/src/plugins/kibana/public/visualize/editor/agg.html @@ -42,7 +42,7 @@ + + + + + + + +
+ + +
+ aggregation.schema.min; }; + // TODO: include metric labels in params in Agg + function setMetricsLabels() { + if ($scope.vis.params.metricsLabels === undefined) { + $scope.vis.params.metricsLabels = {}; + return; + } + + var metricsLabels = $scope.vis.params.metricsLabels; + var firstSibling = $scope; + + // Find the first sibling (scope) + while (firstSibling.$$prevSibling !== null) { + firstSibling = firstSibling.$$prevSibling; + } + + var sibling = firstSibling; + // Travel all siblings setting metric label + while (sibling !== null) { + sibling.metric_label = metricsLabels[sibling.$index]; + sibling = sibling.$$nextSibling; + } + } + + setMetricsLabels(); // Fill with saved labels the metrics labels forms + + $scope.showFormLabel = function () { + $scope.vis.params.metricsLabels[$scope.$index] = $scope.metric_label; + + $scope.showMetricLabel = !$scope.showMetricLabel; + // TODO: Hack, labels should be params so viz.dirty is auto changed + $scope.vis.dirty = true; + }; + + $scope.useAggLabels = function (aggregation) { + var supported = false; + + // Only supported in Metric vis yet + if (aggregation.vis.type.name === 'metric') { + supported = true; + } + return supported; + }; + function calcAggIsTooLow() { if (!$scope.agg.schema.mustBeFirst) { return false; diff --git a/src/plugins/metric_vis/public/metric_vis_controller.js b/src/plugins/metric_vis/public/metric_vis_controller.js index 3ac2ef17c7d22..98efcaf202e82 100644 --- a/src/plugins/metric_vis/public/metric_vis_controller.js +++ b/src/plugins/metric_vis/public/metric_vis_controller.js @@ -12,8 +12,13 @@ define(function (require) { tableGroups.tables.forEach(function (table) { table.columns.forEach(function (column, i) { var fieldFormatter = table.aggConfig(column).fieldFormatter(); + var title; + if ($scope.vis.params.metricsLabels) { + title = $scope.vis.params.metricsLabels[i]; + } metrics.push({ - label: column.title, + // label: column.title, + label: title || column.title, value: fieldFormatter(table.rows[0][i]) }); }); From 271baaa8c7d05b36fecdff12eb9f0c6f4b64aca0 Mon Sep 17 00:00:00 2001 From: Alvaro del Castillo Date: Mon, 19 Oct 2015 21:12:00 +0200 Subject: [PATCH 02/10] Check that $scope.vis is defined for testing env. --- src/plugins/kibana/public/visualize/editor/agg.js | 6 +++++- src/plugins/metric_vis/public/metric_vis_controller.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/kibana/public/visualize/editor/agg.js b/src/plugins/kibana/public/visualize/editor/agg.js index 1535c3926de80..219ca8679a2bb 100644 --- a/src/plugins/kibana/public/visualize/editor/agg.js +++ b/src/plugins/kibana/public/visualize/editor/agg.js @@ -73,6 +73,10 @@ define(function (require) { // TODO: include metric labels in params in Agg function setMetricsLabels() { + if (!$scope.vis) { // For testing + return; + } + if ($scope.vis.params.metricsLabels === undefined) { $scope.vis.params.metricsLabels = {}; return; @@ -108,7 +112,7 @@ define(function (require) { var supported = false; // Only supported in Metric vis yet - if (aggregation.vis.type.name === 'metric') { + if (aggregation.vis && aggregation.vis.type.name === 'metric') { supported = true; } return supported; diff --git a/src/plugins/metric_vis/public/metric_vis_controller.js b/src/plugins/metric_vis/public/metric_vis_controller.js index 98efcaf202e82..01b8abee14030 100644 --- a/src/plugins/metric_vis/public/metric_vis_controller.js +++ b/src/plugins/metric_vis/public/metric_vis_controller.js @@ -13,7 +13,7 @@ define(function (require) { table.columns.forEach(function (column, i) { var fieldFormatter = table.aggConfig(column).fieldFormatter(); var title; - if ($scope.vis.params.metricsLabels) { + if ($scope.vis && $scope.vis.params.metricsLabels) { title = $scope.vis.params.metricsLabels[i]; } metrics.push({ From e5be6a8c909589b2eaf8a55f3ed8fa5fded1e166 Mon Sep 17 00:00:00 2001 From: Alvaro del Castillo Date: Fri, 27 Nov 2015 21:03:41 +0100 Subject: [PATCH 03/10] Labels now working in all visualizations. Some issues pending in Pie chart. --- .../kibana/public/visualize/editor/agg.html | 11 +++---- .../kibana/public/visualize/editor/agg.js | 32 +++++++------------ .../public/metric_vis_controller.js | 7 ++-- src/ui/public/Vis/AggConfig.js | 4 +++ 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/plugins/kibana/public/visualize/editor/agg.html b/src/plugins/kibana/public/visualize/editor/agg.html index 0fb45899d99fc..c916757a2f858 100644 --- a/src/plugins/kibana/public/visualize/editor/agg.html +++ b/src/plugins/kibana/public/visualize/editor/agg.html @@ -53,12 +53,11 @@ - + - + - - - - -