From 305ef74ca787f71a464dab7eb7f497c8349b46ca Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Tue, 22 Apr 2014 16:01:38 -0700 Subject: [PATCH 1/3] Added multiple value columns for each stat type to the stats panel. Removed value field naming --- src/app/panels/stats/editor.html | 16 ++++++++------ src/app/panels/stats/module.html | 38 +++++++++++++++++++++++++------- src/app/panels/stats/module.js | 20 ++++++++++++++--- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/app/panels/stats/editor.html b/src/app/panels/stats/editor.html index 4d9a6186f4cc1..08e93e6d75dc2 100644 --- a/src/app/panels/stats/editor.html +++ b/src/app/panels/stats/editor.html @@ -1,8 +1,8 @@
Details
- - + +
@@ -12,6 +12,12 @@
Details
+ +
Columns
+
+ +
+
Formating
@@ -26,11 +32,7 @@
Formating
- +
-
- - -
diff --git a/src/app/panels/stats/module.html b/src/app/panels/stats/module.html index b9810bdc8f5f4..aca958e790688 100644 --- a/src/app/panels/stats/module.html +++ b/src/app/panels/stats/module.html @@ -1,14 +1,36 @@
-

{{data.value|formatstats:panel.format}} {{panel.unit}}

- + + +

{{data.value|formatstats:panel.format}} {{panel.unit}} ({{panel.mode}})

+
- - - - - + + + + + + + - + + +
{{panel.label_name}} {{panel.value_name}}
{{panel.label_name}} + + {{stat}} + +
{{item.label}}{{item.value|formatstats:panel.format}} {{panel.unit}}{{item.value[stat]|formatstats:panel.format}} {{panel.unit}}
diff --git a/src/app/panels/stats/module.js b/src/app/panels/stats/module.js index 20fa35c67ff55..94c905e5f9dcb 100644 --- a/src/app/panels/stats/module.js +++ b/src/app/panels/stats/module.js @@ -48,6 +48,7 @@ define([ description: 'A statistical panel for displaying aggregations using the Elastic Search statistical facet query.' }; + $scope.modes = ['count','min','max','mean','total','variance','std_deviation','sum_of_squares']; var defaults = { queries : { @@ -62,7 +63,17 @@ define([ sort_reverse: false, label_name: 'Query', value_name: 'Value', - spyable : true + spyable : true, + show: { + count: true, + min: true, + max: true, + mean: true, + std_deviation: true, + sum_of_squares: true, + total: true, + variance: true + } }; _.defaults($scope.panel, defaults); @@ -76,6 +87,7 @@ define([ }; $scope.set_sort = function(field) { + console.log(field); if($scope.panel.sort_field === field && $scope.panel.sort_reverse === false) { $scope.panel.sort_reverse = true; } else if($scope.panel.sort_field === field && $scope.panel.sort_reverse === true) { @@ -149,8 +161,8 @@ define([ var obj = _.clone(q); obj.label = alias; obj.Label = alias.toLowerCase(); //sort field - obj.value = results.facets['stats_'+alias][$scope.panel.mode]; - obj.Value = results.facets['stats_'+alias][$scope.panel.mode]; //sort field + obj.value = results.facets['stats_'+alias]; + obj.Value = results.facets['stats_'+alias]; //sort field return obj; }); @@ -159,6 +171,8 @@ define([ rows: rows }; + console.log($scope.data); + $scope.$emit('render'); }); }; From 49c6b49dd5d37022672410c6164067cfabefede6 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Tue, 22 Apr 2014 16:03:41 -0700 Subject: [PATCH 2/3] Include jsonpath --- .jshintrc | 3 +- src/app/components/require.config.js | 7 ++- src/vendor/jsonpath.js | 87 ++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 src/vendor/jsonpath.js diff --git a/.jshintrc b/.jshintrc index 54051651ff684..0c92156f6b688 100644 --- a/.jshintrc +++ b/.jshintrc @@ -29,6 +29,7 @@ "globals": { "define": true, "require": true, - "Chromath": false + "Chromath": false, + "jsonPath": false } } \ No newline at end of file diff --git a/src/app/components/require.config.js b/src/app/components/require.config.js index 5ea06e09a5630..43657a171eb42 100644 --- a/src/app/components/require.config.js +++ b/src/app/components/require.config.js @@ -45,7 +45,8 @@ require.config({ modernizr: '../vendor/modernizr-2.6.1', - numeral: '../vendor/numeral', + numeral: '../vendor/numeral', + jsonpath: '../vendor/jsonpath', elasticjs: '../vendor/elasticjs/elastic-angular-client', }, shim: { @@ -62,6 +63,10 @@ require.config({ exports: 'Modernizr' }, + jsonpath: { + exports: 'jsonPath' + }, + jquery: { exports: 'jQuery' }, diff --git a/src/vendor/jsonpath.js b/src/vendor/jsonpath.js new file mode 100644 index 0000000000000..bafe5e338454e --- /dev/null +++ b/src/vendor/jsonpath.js @@ -0,0 +1,87 @@ +/* JSONPath 0.8.0 - XPath for JSON + * + * Copyright (c) 2007 Stefan Goessner (goessner.net) + * Licensed under the MIT (MIT-LICENSE.txt) licence. + */ +function jsonPath(obj, expr, arg) { + var P = { + resultType: arg && arg.resultType || "VALUE", + result: [], + normalize: function(expr) { + var subx = []; + return expr.replace(/[\['](\??\(.*?\))[\]']/g, function($0,$1){return "[#"+(subx.push($1)-1)+"]";}) + .replace(/'?\.'?|\['?/g, ";") + .replace(/;;;|;;/g, ";..;") + .replace(/;$|'?\]|'$/g, "") + .replace(/#([0-9]+)/g, function($0,$1){return subx[$1];}); + }, + asPath: function(path) { + var x = path.split(";"), p = "$"; + for (var i=1,n=x.length; i Date: Tue, 22 Apr 2014 21:25:10 -0700 Subject: [PATCH 3/3] Add stats facet to numeric fields in table --- src/app/panels/table/micropanel.html | 7 +++- src/app/panels/table/module.html | 2 +- src/app/panels/table/module.js | 53 ++++++++++++++++++---------- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/app/panels/table/micropanel.html b/src/app/panels/table/micropanel.html index d3983031828f7..f7368fcde5989 100644 --- a/src/app/panels/table/micropanel.html +++ b/src/app/panels/table/micropanel.html @@ -5,7 +5,7 @@ - Micro Analysis of {{micropanel.field}} + Micro Analysis of {{micropanel.field}} ({{micropanel.type}}) as Groups / @@ -59,6 +59,11 @@
  • Table
  • +
    + + Stats + +
    \ No newline at end of file diff --git a/src/app/panels/table/module.html b/src/app/panels/table/module.html index f0780603e07ed..19f6412732320 100644 --- a/src/app/panels/table/module.html +++ b/src/app/panels/table/module.html @@ -103,7 +103,7 @@

    - Top 10 terms in field {{modalField}} + {{adhocOpts.title}} 0) { + $scope.micropanel.hasStats = true; + } + }); + }; $scope.micropanelColor = function(index) {