Skip to content

Commit

Permalink
reverting changes to table
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Feb 12, 2020
1 parent 09fd301 commit 06becac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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]
Expand Down
14 changes: 11 additions & 3 deletions src/legacy/core_plugins/vis_type_table/public/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 06becac

Please sign in to comment.