From 06becacabbafe86539d12fa9ef028e3a0088ba2a Mon Sep 17 00:00:00 2001 From: ppisljar Date: Wed, 12 Feb 2020 08:55:56 -0500 Subject: [PATCH] reverting changes to table --- .../public/components/table_vis_options.tsx | 5 +---- .../vis_type_table/public/components/utils.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx b/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx index efead8a6e1d56..72838d2d97421 100644 --- a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx +++ b/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx @@ -24,7 +24,6 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { VisOptionsProps } from 'src/legacy/core_plugins/vis_default_editor/public'; -import { createFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; import { tabifyGetColumns } from '../legacy_imports'; import { NumberInputOption, SwitchOption, SelectOption } from '../../../vis_type_vislib/public'; import { TableVisParams } from '../types'; @@ -45,9 +44,7 @@ function TableOptions({ }), }, ...tabifyGetColumns(aggs.getResponseAggs(), true) - .filter(col => - isAggConfigNumeric(get(col, 'aggConfig.type.name'), createFormat(col.aggConfig)) - ) + .filter(col => isAggConfigNumeric(get(col, 'aggConfig.type.name'), stateParams.dimensions)) .map(({ name }) => ({ value: name, text: name })), ], [aggs, stateParams.percentageCol, stateParams.dimensions] diff --git a/src/legacy/core_plugins/vis_type_table/public/components/utils.ts b/src/legacy/core_plugins/vis_type_table/public/components/utils.ts index 118e5d2175ed5..365566503e25b 100644 --- a/src/legacy/core_plugins/vis_type_table/public/components/utils.ts +++ b/src/legacy/core_plugins/vis_type_table/public/components/utils.ts @@ -17,11 +17,19 @@ * under the License. */ +import { get } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { AggTypes } from '../types'; +import { AggTypes, Dimensions } from '../types'; -function isAggConfigNumeric(type: AggTypes, format: any) { - return format.id === 'number'; +function isAggConfigNumeric( + type: AggTypes, + { buckets, metrics }: Dimensions = { buckets: [], metrics: [] } +) { + const dimension = + buckets.find(({ aggType }) => aggType === type) || + metrics.find(({ aggType }) => aggType === type); + const formatType = get(dimension, 'format.id') || get(dimension, 'format.params.id'); + return formatType === 'number'; } const totalAggregations = [