diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index df2f8011562..dacb59f4440 100755 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -61,23 +61,41 @@ function($, _) { return value; }; - kbn.top_field_values = function(docs,field,count) { + kbn.top_field_values = function(docs,field,count,grouped) { var all_values = _.pluck(docs,field), - groups = {}; - + groups = {}, + counts, + hasArrays; // manually grouping into pairs allows us to keep the original value, _.each(all_values, function (value) { - var key = _.isUndefined(value) ? '' : value.toString(); - if (_.has(groups, key)) { - groups[key][1] ++; - } else { - groups[key] = [value, 1]; + var k; + if(_.isArray(value)) { + hasArrays = true; } + if(_.isArray(value) && !grouped) { + k = value; + } else { + k = _.isUndefined(value) ? '' : [value.toString()]; + } + _.each(k, function(key) { + if (_.has(groups, key)) { + groups[key][1] ++; + } else { + groups[key] = [(grouped ? value : key), 1]; + } + }); }); - return _.values(groups).sort(function(a, b) { + counts = _.values(groups).sort(function(a, b) { return a[1] - b[1]; }).reverse().slice(0,count); + + console.log(hasArrays); + + return { + counts: counts, + hasArrays : hasArrays + }; }; /** diff --git a/src/app/panels/table/micropanel.html b/src/app/panels/table/micropanel.html index 18b572fe44d..3abed9b26aa 100755 --- a/src/app/panels/table/micropanel.html +++ b/src/app/panels/table/micropanel.html @@ -3,22 +3,30 @@ Micro Analysis of {{micropanel.field}} -
{{micropanel.count}} events in the table set +
+ + {{micropanel.count}} events in the table set + + as + Groups / + Singles + + - +
- - - + + + - - + -
{{micropanel.field}}ActionCount{{micropanel.field}}ActionCount
{{{true: "__blank__", false:field[0] }[field[0] == '' || field[0] == undefined]|tableTruncate:panel.trimFactor:3}} + {{{true: "__blank__", false:field[0] }[field[0] == '' || field[0] == undefined]|tableTruncate:panel.trimFactor:3}} +