corrected display of arrays in the metric vis

This commit is contained in:
Stéphane Campinas 2016-12-17 15:27:36 +00:00
parent 2a2fa67d2a
commit eb70e84a56
No known key found for this signature in database
GPG key ID: 8272664236A42C2F
2 changed files with 9 additions and 8 deletions

View file

@ -21,7 +21,7 @@ describe('metric vis', function () {
$scope.processTableGroups({ $scope.processTableGroups({
tables: [{ tables: [{
columns: [{ title: 'Count' }], columns: [{ title: 'Count' }],
rows: [[4301021]], rows: [[ { toString: () => formatter(4301021) } ]],
aggConfig: function () { aggConfig: function () {
return { return {
fieldFormatter: function () { fieldFormatter: function () {
@ -44,7 +44,7 @@ describe('metric vis', function () {
{ title: '1st percentile of bytes' }, { title: '1st percentile of bytes' },
{ title: '99th percentile of bytes' } { title: '99th percentile of bytes' }
], ],
rows: [[182, 445842.4634666484]], rows: [[ { toString: () => formatter(182) }, { toString: () => formatter(445842.4634666484) } ]],
aggConfig: function () { aggConfig: function () {
return { return {
fieldFormatter: function () { fieldFormatter: function () {

View file

@ -17,14 +17,11 @@ module.controller('KbnMetricVisController', function ($scope, $element, Private)
$scope.processTableGroups = function (tableGroups) { $scope.processTableGroups = function (tableGroups) {
tableGroups.tables.forEach(function (table) { tableGroups.tables.forEach(function (table) {
table.columns.forEach(function (column, i) { table.columns.forEach(function (column, i) {
const fieldFormatter = table.aggConfig(column).fieldFormatter(); const value = table.rows[0][i];
let value = table.rows[0][i];
value = isInvalid(value) ? '?' : fieldFormatter(value);
metrics.push({ metrics.push({
label: column.title, label: column.title,
value: value value: value.toString('html')
}); });
}); });
}); });
@ -32,8 +29,12 @@ module.controller('KbnMetricVisController', function ($scope, $element, Private)
$scope.$watch('esResponse', function (resp) { $scope.$watch('esResponse', function (resp) {
if (resp) { if (resp) {
const options = {
asAggConfigResults: true
};
metrics.length = 0; metrics.length = 0;
$scope.processTableGroups(tabifyAggResponse($scope.vis, resp)); $scope.processTableGroups(tabifyAggResponse($scope.vis, resp, options));
$element.trigger('renderComplete'); $element.trigger('renderComplete');
} }
}); });