diff --git a/x-pack/examples/embedded_lens_example/public/app.tsx b/x-pack/examples/embedded_lens_example/public/app.tsx index 3921b3a51dc45..f1b683f2430f7 100644 --- a/x-pack/examples/embedded_lens_example/public/app.tsx +++ b/x-pack/examples/embedded_lens_example/public/app.tsx @@ -27,6 +27,7 @@ import { PersistedIndexPatternLayer, XYState, LensEmbeddableInput, + DateHistogramIndexPatternColumn, } from '../../../plugins/lens/public'; import { StartDependencies } from './plugin'; @@ -55,7 +56,7 @@ function getLensAttributes( params: { interval: 'auto' }, scale: 'interval', sourceField: defaultIndexPattern.timeFieldName!, - }, + } as DateHistogramIndexPatternColumn, }, }; diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts index db04712271587..70aa103b86d53 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts @@ -10,7 +10,10 @@ import type { Filter } from '@kbn/es-query'; import type { IndexPattern } from '../../../../../../../../../src/plugins/data/common'; import type { CombinedQuery } from '../../../../index_data_visualizer/types/combined_query'; import type { - IndexPatternColumn, + DateHistogramIndexPatternColumn, + GenericIndexPatternColumn, + RangeIndexPatternColumn, + TermsIndexPatternColumn, TypedLensByValueInput, XYLayerConfig, } from '../../../../../../../lens/public'; @@ -18,7 +21,7 @@ import { FieldVisConfig } from '../../stats_table/types'; import { JOB_FIELD_TYPES } from '../../../../../../common'; interface ColumnsAndLayer { - columns: Record; + columns: Record; layer: XYLayerConfig; } @@ -32,7 +35,7 @@ const COUNT = i18n.translate('xpack.dataVisualizer.index.lensChart.countLabel', export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: IndexPattern) { // if index has no timestamp field if (defaultIndexPattern.timeFieldName === undefined) { - const columns: Record = { + const columns: Record = { col1: { label: item.fieldName!, dataType: 'number', @@ -44,7 +47,7 @@ export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: Ind ranges: [], }, sourceField: item.fieldName!, - }, + } as RangeIndexPatternColumn, col2: { label: COUNT, dataType: 'number', @@ -64,7 +67,7 @@ export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: Ind return { columns, layer }; } - const columns: Record = { + const columns: Record = { col2: { dataType: 'number', isBucketed: false, @@ -83,7 +86,7 @@ export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: Ind params: { interval: 'auto' }, scale: 'interval', sourceField: defaultIndexPattern.timeFieldName!, - }, + } as DateHistogramIndexPatternColumn, }; const layer: XYLayerConfig = { @@ -97,7 +100,7 @@ export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: Ind return { columns, layer }; } export function getDateSettings(item: FieldVisConfig) { - const columns: Record = { + const columns: Record = { col2: { dataType: 'number', isBucketed: false, @@ -114,7 +117,7 @@ export function getDateSettings(item: FieldVisConfig) { params: { interval: 'auto' }, scale: 'interval', sourceField: item.fieldName!, - }, + } as DateHistogramIndexPatternColumn, }; const layer: XYLayerConfig = { accessors: ['col2'], @@ -128,7 +131,7 @@ export function getDateSettings(item: FieldVisConfig) { } export function getKeywordSettings(item: FieldVisConfig) { - const columns: Record = { + const columns: Record = { col1: { label: TOP_VALUES_LABEL, dataType: 'string', @@ -140,7 +143,7 @@ export function getKeywordSettings(item: FieldVisConfig) { orderDirection: 'desc', }, sourceField: item.fieldName!, - }, + } as TermsIndexPatternColumn, col2: { label: COUNT, dataType: 'number', @@ -161,7 +164,7 @@ export function getKeywordSettings(item: FieldVisConfig) { } export function getBooleanSettings(item: FieldVisConfig) { - const columns: Record = { + const columns: Record = { col1: { label: TOP_VALUES_LABEL, dataType: 'string', @@ -173,7 +176,7 @@ export function getBooleanSettings(item: FieldVisConfig) { orderDirection: 'desc', }, sourceField: item.fieldName!, - }, + } as TermsIndexPatternColumn, col2: { label: COUNT, dataType: 'number', diff --git a/x-pack/plugins/lens/public/index.ts b/x-pack/plugins/lens/public/index.ts index 8a7c089260a39..29dce6f0d1090 100644 --- a/x-pack/plugins/lens/public/index.ts +++ b/x-pack/plugins/lens/public/index.ts @@ -33,6 +33,8 @@ export type { PersistedIndexPatternLayer, OperationType, IncompleteColumn, + GenericIndexPatternColumn, + FieldBasedIndexPatternColumn, FiltersIndexPatternColumn, RangeIndexPatternColumn, TermsIndexPatternColumn, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/types.ts b/x-pack/plugins/lens/public/indexpattern_datasource/types.ts index 5561d5097e2a7..a0d43c5523c5b 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/types.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/types.ts @@ -15,6 +15,7 @@ export type { GenericIndexPatternColumn, OperationType, IncompleteColumn, + FieldBasedIndexPatternColumn, FiltersIndexPatternColumn, RangeIndexPatternColumn, TermsIndexPatternColumn,