diff --git a/src/plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap b/src/plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap index a212cec2d8827..a3be4d10d9bfd 100644 --- a/src/plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap +++ b/src/plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap @@ -1,5 +1,25 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`interpreter/functions#metric logs correct datatable to inspector 1`] = ` +Object { + "columns": Array [ + Object { + "id": "col-0-1", + "meta": Object { + "dimensionName": undefined, + }, + "name": "Count", + }, + ], + "rows": Array [ + Object { + "col-0-1": 0, + }, + ], + "type": "datatable", +} +`; + exports[`interpreter/functions#metric returns an object with the correct structure 1`] = ` Object { "as": "metric_vis", diff --git a/src/plugins/vis_type_metric/public/metric_vis_fn.test.ts b/src/plugins/vis_type_metric/public/metric_vis_fn.test.ts index 35d8a2d5fd837..432b1f2fe02b7 100644 --- a/src/plugins/vis_type_metric/public/metric_vis_fn.test.ts +++ b/src/plugins/vis_type_metric/public/metric_vis_fn.test.ts @@ -8,6 +8,7 @@ import { createMetricVisFn } from './metric_vis_fn'; import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils'; +import { Datatable } from '../../expressions/common/expression_types/specs'; describe('interpreter/functions#metric', () => { const fn = functionWrapper(createMetricVisFn()); @@ -56,4 +57,20 @@ describe('interpreter/functions#metric', () => { expect(actual).toMatchSnapshot(); }); + + it('logs correct datatable to inspector', async () => { + let loggedTable: Datatable; + const handlers = { + inspectorAdapters: { + tables: { + logDatatable: (name: string, datatable: Datatable) => { + loggedTable = datatable; + }, + }, + }, + }; + await fn(context, args, handlers as any); + + expect(loggedTable!).toMatchSnapshot(); + }); }); diff --git a/src/plugins/vis_type_metric/public/metric_vis_fn.ts b/src/plugins/vis_type_metric/public/metric_vis_fn.ts index 9904bee22be65..ab62c3e941e28 100644 --- a/src/plugins/vis_type_metric/public/metric_vis_fn.ts +++ b/src/plugins/vis_type_metric/public/metric_vis_fn.ts @@ -16,6 +16,7 @@ import { Style, } from '../../expressions/public'; import { visType, DimensionsVisParam, VisParams } from './types'; +import { prepareLogTable, Dimension } from '../../visualizations/public'; import { ColorSchemas, vislibColorMaps, ColorMode } from '../../charts/public'; export type Input = Datatable; @@ -164,7 +165,24 @@ export const createMetricVisFn = (): MetricVisExpressionFunctionDefinition => ({ const fontSize = Number.parseInt(args.font.spec.fontSize || '', 10); if (handlers?.inspectorAdapters?.tables) { - handlers.inspectorAdapters.tables.logDatatable('default', input); + const argsTable: Dimension[] = [ + [ + args.metric, + i18n.translate('visTypeMetric.function.dimension.metric', { + defaultMessage: 'Metric', + }), + ], + ]; + if (args.bucket) { + argsTable.push([ + [args.bucket], + i18n.translate('visTypeMetric.function.adimension.splitGroup', { + defaultMessage: 'Split group', + }), + ]); + } + const logTable = prepareLogTable(input, argsTable); + handlers.inspectorAdapters.tables.logDatatable('default', logTable); } return { type: 'render', diff --git a/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap b/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap index f3d1b134bf19a..be7e2822f128d 100644 --- a/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap +++ b/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap @@ -1,5 +1,25 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`interpreter/functions#table logs correct datatable to inspector 1`] = ` +Object { + "columns": Array [ + Object { + "id": "col-0-1", + "meta": Object { + "dimensionName": "Metrics", + }, + "name": "Count", + }, + ], + "rows": Array [ + Object { + "col-0-1": 0, + }, + ], + "type": "datatable", +} +`; + exports[`interpreter/functions#table returns an object with the correct structure 1`] = ` Object { "as": "table_vis", diff --git a/src/plugins/vis_type_table/public/table_vis_fn.test.ts b/src/plugins/vis_type_table/public/table_vis_fn.test.ts index 5b7be5dea7c85..c6eb8601824ec 100644 --- a/src/plugins/vis_type_table/public/table_vis_fn.test.ts +++ b/src/plugins/vis_type_table/public/table_vis_fn.test.ts @@ -10,6 +10,7 @@ import { createTableVisFn } from './table_vis_fn'; import { tableVisResponseHandler } from './utils'; import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils'; +import { Datatable } from '../../expressions/common/expression_types/specs'; jest.mock('./utils', () => ({ tableVisResponseHandler: jest.fn().mockReturnValue({ @@ -67,4 +68,20 @@ describe('interpreter/functions#table', () => { expect(tableVisResponseHandler).toHaveBeenCalledTimes(1); expect(tableVisResponseHandler).toHaveBeenCalledWith(context, visConfig); }); + + it('logs correct datatable to inspector', async () => { + let loggedTable: Datatable; + const handlers = { + inspectorAdapters: { + tables: { + logDatatable: (name: string, datatable: Datatable) => { + loggedTable = datatable; + }, + }, + }, + }; + await fn(context, visConfig, handlers as any); + + expect(loggedTable!).toMatchSnapshot(); + }); }); diff --git a/src/plugins/vis_type_table/public/table_vis_fn.ts b/src/plugins/vis_type_table/public/table_vis_fn.ts index abc8a0d9cd90c..9473a9a2663ab 100644 --- a/src/plugins/vis_type_table/public/table_vis_fn.ts +++ b/src/plugins/vis_type_table/public/table_vis_fn.ts @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import { ExpressionFunctionDefinition, Datatable, Render } from '../../expressions/public'; +import { prepareLogTable, Dimension } from '../../visualizations/public'; import { TableVisData, TableVisConfig } from './types'; import { VIS_TYPE_TABLE } from '../common'; import { tableVisResponseHandler } from './utils'; @@ -122,7 +123,38 @@ export const createTableVisFn = (): TableExpressionFunctionDefinition => ({ const convertedData = tableVisResponseHandler(input, args); if (handlers?.inspectorAdapters?.tables) { - handlers.inspectorAdapters.tables.logDatatable('default', input); + const argsTable: Dimension[] = [ + [ + args.metrics, + i18n.translate('visTypeTable.function.dimension.metrics', { + defaultMessage: 'Metrics', + }), + ], + [ + args.buckets, + i18n.translate('visTypeTable.function.adimension.buckets', { + defaultMessage: 'Buckets', + }), + ], + ]; + if (args.splitColumn) { + argsTable.push([ + [args.splitColumn], + i18n.translate('visTypeTable.function.dimension.splitColumn', { + defaultMessage: 'Split by column', + }), + ]); + } + if (args.splitRow) { + argsTable.push([ + [args.splitRow], + i18n.translate('visTypeTable.function.dimension.splitRow', { + defaultMessage: 'Split by row', + }), + ]); + } + const logTable = prepareLogTable(input, argsTable); + handlers.inspectorAdapters.tables.logDatatable('default', logTable); } return { type: 'render', diff --git a/src/plugins/vis_type_tagcloud/public/__snapshots__/tag_cloud_fn.test.ts.snap b/src/plugins/vis_type_tagcloud/public/__snapshots__/tag_cloud_fn.test.ts.snap index cbfece0b081c6..2888d7637546c 100644 --- a/src/plugins/vis_type_tagcloud/public/__snapshots__/tag_cloud_fn.test.ts.snap +++ b/src/plugins/vis_type_tagcloud/public/__snapshots__/tag_cloud_fn.test.ts.snap @@ -1,5 +1,25 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`interpreter/functions#tagcloud logs correct datatable to inspector 1`] = ` +Object { + "columns": Array [ + Object { + "id": "col-0-1", + "meta": Object { + "dimensionName": "Tag size", + }, + "name": "Count", + }, + ], + "rows": Array [ + Object { + "col-0-1": 0, + }, + ], + "type": "datatable", +} +`; + exports[`interpreter/functions#tagcloud returns an object with the correct structure 1`] = ` Object { "as": "tagloud_vis", diff --git a/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.test.ts b/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.test.ts index 5dcdffffde01d..1671c0b01a666 100644 --- a/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.test.ts +++ b/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.test.ts @@ -9,6 +9,7 @@ import { createTagCloudFn } from './tag_cloud_fn'; import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils'; +import { Datatable } from '../../expressions/common/expression_types/specs'; describe('interpreter/functions#tagcloud', () => { const fn = functionWrapper(createTagCloudFn()); @@ -31,4 +32,20 @@ describe('interpreter/functions#tagcloud', () => { const actual = fn(context, visConfig, undefined); expect(actual).toMatchSnapshot(); }); + + it('logs correct datatable to inspector', async () => { + let loggedTable: Datatable; + const handlers = { + inspectorAdapters: { + tables: { + logDatatable: (name: string, datatable: Datatable) => { + loggedTable = datatable; + }, + }, + }, + }; + await fn(context, visConfig, handlers as any); + + expect(loggedTable!).toMatchSnapshot(); + }); }); diff --git a/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.ts b/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.ts index 17855db9150b5..bfaf557c6baff 100644 --- a/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.ts +++ b/src/plugins/vis_type_tagcloud/public/tag_cloud_fn.ts @@ -9,6 +9,7 @@ import { i18n } from '@kbn/i18n'; import { ExpressionFunctionDefinition, Datatable, Render } from '../../expressions/public'; +import { prepareLogTable, Dimension } from '../../visualizations/public'; import { TagCloudVisParams, TagCloudVisConfig } from './types'; const name = 'tagcloud'; @@ -109,7 +110,24 @@ export const createTagCloudFn = (): TagcloudExpressionFunctionDefinition => ({ } as TagCloudVisParams; if (handlers?.inspectorAdapters?.tables) { - handlers.inspectorAdapters.tables.logDatatable('default', input); + const argsTable: Dimension[] = [ + [ + [args.metric], + i18n.translate('visTypeTagCloud.function.dimension.tagSize', { + defaultMessage: 'Tag size', + }), + ], + ]; + if (args.bucket) { + argsTable.push([ + [args.bucket], + i18n.translate('visTypeTagCloud.function.adimension.tags', { + defaultMessage: 'Tags', + }), + ]); + } + const logTable = prepareLogTable(input, argsTable); + handlers.inspectorAdapters.tables.logDatatable('default', logTable); } return { type: 'render', diff --git a/src/plugins/vis_type_vislib/public/to_ast.ts b/src/plugins/vis_type_vislib/public/to_ast.ts index 5894b4be964e0..1e33c589ff1fc 100644 --- a/src/plugins/vis_type_vislib/public/to_ast.ts +++ b/src/plugins/vis_type_vislib/public/to_ast.ts @@ -15,7 +15,9 @@ import { VisParams, } from '../../visualizations/public'; import { buildExpression, buildExpressionFunction } from '../../expressions/public'; -import type { Dimensions, DateHistogramParams, HistogramParams } from '../../vis_type_xy/public'; +import type { Dimensions } from '../../vis_type_xy/public'; +import type { DateHistogramParams, HistogramParams } from '../../visualizations/public'; + import { BUCKET_TYPES } from '../../data/public'; import { vislibVisName, VisTypeVislibExpressionFunctionDefinition } from './vis_type_vislib_vis_fn'; diff --git a/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_init_x_axis.test.ts b/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_init_x_axis.test.ts index 3c489539d6b2e..cb0ebe563f54b 100644 --- a/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_init_x_axis.test.ts +++ b/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_init_x_axis.test.ts @@ -8,7 +8,7 @@ import moment from 'moment'; -import type { DateHistogramParams, HistogramParams } from '../../../../../vis_type_xy/public'; +import type { DateHistogramParams, HistogramParams } from '../../../../../visualizations/public'; import { initXAxis } from './_init_x_axis'; import { makeFakeXAspect } from './_fake_x_aspect'; diff --git a/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_ordered_date_axis.test.ts b/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_ordered_date_axis.test.ts index ebfcacc83de5c..4dfa5035275fb 100644 --- a/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_ordered_date_axis.test.ts +++ b/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/_ordered_date_axis.test.ts @@ -9,7 +9,7 @@ import moment from 'moment'; import _ from 'lodash'; -import type { DateHistogramParams } from '../../../../../vis_type_xy/public/types'; +import type { DateHistogramParams } from '../../../../../visualizations/public'; import { orderedDateAxis } from './_ordered_date_axis'; import { OrderedChart } from './point_series'; diff --git a/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/point_series.ts b/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/point_series.ts index db2b738681cd1..62be39ffb8a73 100644 --- a/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/point_series.ts +++ b/src/plugins/vis_type_vislib/public/vislib/helpers/point_series/point_series.ts @@ -8,12 +8,8 @@ import { Duration } from 'moment'; -import type { - Dimension, - Dimensions, - DateHistogramParams, - HistogramParams, -} from '../../../../../vis_type_xy/public'; +import type { Dimension, Dimensions } from '../../../../../vis_type_xy/public'; +import type { DateHistogramParams, HistogramParams } from '../../../../../visualizations/public'; import { getSeries } from './_get_series'; import { getAspects } from './_get_aspects'; diff --git a/src/plugins/vis_type_xy/public/config/get_config.ts b/src/plugins/vis_type_xy/public/config/get_config.ts index ce01572060a40..0c687aa918056 100644 --- a/src/plugins/vis_type_xy/public/config/get_config.ts +++ b/src/plugins/vis_type_xy/public/config/get_config.ts @@ -10,11 +10,11 @@ import { ScaleContinuousType } from '@elastic/charts'; import { Datatable } from '../../../expressions/public'; import { BUCKET_TYPES } from '../../../data/public'; +import { DateHistogramParams } from '../../../visualizations/public'; import { Aspect, AxisConfig, - DateHistogramParams, SeriesParam, VisConfig, VisParams, diff --git a/src/plugins/vis_type_xy/public/expression_functions/index.ts b/src/plugins/vis_type_xy/public/expression_functions/index.ts index 4e7db57ee65d7..32c50e3adff1e 100644 --- a/src/plugins/vis_type_xy/public/expression_functions/index.ts +++ b/src/plugins/vis_type_xy/public/expression_functions/index.ts @@ -15,4 +15,3 @@ export { seriesParam, ExpressionValueSeriesParam } from './series_param'; export { thresholdLine, ExpressionValueThresholdLine } from './threshold_line'; export { label, ExpressionValueLabel } from './label'; export { visScale, ExpressionValueScale } from './vis_scale'; -export { xyDimension, ExpressionValueXYDimension } from './xy_dimension'; diff --git a/src/plugins/vis_type_xy/public/expression_functions/xy_vis_fn.ts b/src/plugins/vis_type_xy/public/expression_functions/xy_vis_fn.ts index 29403a12fdce6..35f3b2d7c627d 100644 --- a/src/plugins/vis_type_xy/public/expression_functions/xy_vis_fn.ts +++ b/src/plugins/vis_type_xy/public/expression_functions/xy_vis_fn.ts @@ -8,7 +8,8 @@ import { i18n } from '@kbn/i18n'; -import type { ExpressionFunctionDefinition, Datatable, Render } from '../../../expressions/public'; +import type { ExpressionFunctionDefinition, Datatable, Render } from '../../../expressions/common'; +import { prepareLogTable, Dimension } from '../../../visualizations/public'; import type { ChartType } from '../../common'; import type { VisParams, XYVisConfig } from '../types'; @@ -262,7 +263,44 @@ export const visTypeXyVisFn = (): VisTypeXyExpressionFunctionDefinition => ({ } as VisParams; if (handlers?.inspectorAdapters?.tables) { - handlers.inspectorAdapters.tables.logDatatable('default', context); + const argsTable: Dimension[] = [ + [ + args.yDimension, + i18n.translate('visTypeXy.function.dimension.metric', { + defaultMessage: 'Metric', + }), + ], + [ + args.zDimension, + i18n.translate('visTypeXy.function.adimension.dotSize', { + defaultMessage: 'Dot size', + }), + ], + [ + args.splitColumnDimension, + i18n.translate('visTypeXy.function.dimension.splitcolumn', { + defaultMessage: 'Column split', + }), + ], + [ + args.splitRowDimension, + i18n.translate('visTypeXy.function.dimension.splitrow', { + defaultMessage: 'Row split', + }), + ], + ]; + + if (args.xDimension) { + argsTable.push([ + [args.xDimension], + i18n.translate('visTypeXy.function.adimension.bucket', { + defaultMessage: 'Bucket', + }), + ]); + } + + const logTable = prepareLogTable(context, argsTable); + handlers.inspectorAdapters.tables.logDatatable('default', logTable); } return { diff --git a/src/plugins/vis_type_xy/public/index.ts b/src/plugins/vis_type_xy/public/index.ts index 8691ad606da95..55fa84c72603e 100644 --- a/src/plugins/vis_type_xy/public/index.ts +++ b/src/plugins/vis_type_xy/public/index.ts @@ -22,8 +22,6 @@ export { Dimensions, ScaleType, AxisType, - HistogramParams, - DateHistogramParams, } from './types'; export type { ValidationVisOptionsProps } from './editor/components/common/validation_wrapper'; export { TruncateLabelsOption } from './editor/components/common/truncate_labels'; diff --git a/src/plugins/vis_type_xy/public/plugin.ts b/src/plugins/vis_type_xy/public/plugin.ts index b595d3172f143..9e1e7354c8a69 100644 --- a/src/plugins/vis_type_xy/public/plugin.ts +++ b/src/plugins/vis_type_xy/public/plugin.ts @@ -77,7 +77,6 @@ export class VisTypeXyPlugin expressions.registerFunction(expressionFunctions.thresholdLine); expressions.registerFunction(expressionFunctions.label); expressions.registerFunction(expressionFunctions.visScale); - expressions.registerFunction(expressionFunctions.xyDimension); visTypesDefinitions.forEach(visualizations.createBaseVisualization); } diff --git a/src/plugins/vis_type_xy/public/to_ast.ts b/src/plugins/vis_type_xy/public/to_ast.ts index f473cd77c2d2b..9fec3f99ab39b 100644 --- a/src/plugins/vis_type_xy/public/to_ast.ts +++ b/src/plugins/vis_type_xy/public/to_ast.ts @@ -8,16 +8,19 @@ import moment from 'moment'; -import { VisToExpressionAst, getVisSchemas } from '../../visualizations/public'; +import { + VisToExpressionAst, + getVisSchemas, + DateHistogramParams, + HistogramParams, +} from '../../visualizations/public'; import { buildExpression, buildExpressionFunction } from '../../expressions/public'; import { BUCKET_TYPES } from '../../data/public'; import { Labels } from '../../charts/public'; import { - DateHistogramParams, Dimensions, Dimension, - HistogramParams, VisParams, CategoryAxis, SeriesParam, diff --git a/src/plugins/vis_type_xy/public/types/param.ts b/src/plugins/vis_type_xy/public/types/param.ts index 7a2ff7e240264..421690f7fc6a9 100644 --- a/src/plugins/vis_type_xy/public/types/param.ts +++ b/src/plugins/vis_type_xy/public/types/param.ts @@ -8,7 +8,13 @@ import type { Fit, Position } from '@elastic/charts'; import type { Style, Labels, PaletteOutput } from '../../../charts/public'; -import type { SchemaConfig } from '../../../visualizations/public'; +import type { + SchemaConfig, + ExpressionValueXYDimension, + FakeParams, + HistogramParams, + DateHistogramParams, +} from '../../../visualizations/public'; import type { ChartType, XyVisType } from '../../common'; import type { ExpressionValueCategoryAxis, @@ -17,7 +23,6 @@ import type { ExpressionValueLabel, ExpressionValueThresholdLine, ExpressionValueTimeMarker, - ExpressionValueXYDimension, } from '../expression_functions'; import type { @@ -96,26 +101,6 @@ export interface TimeMarker { width?: number; } -export interface DateHistogramParams { - date: boolean; - interval: number; - intervalESValue: number; - intervalESUnit: string; - format: string; - bounds?: { - min: string | number; - max: string | number; - }; -} - -export interface HistogramParams { - interval: number; -} - -export interface FakeParams { - defaultValue: string; -} - export type Dimension = Omit & { params: DateHistogramParams | HistogramParams | FakeParams | {}; }; diff --git a/src/plugins/vis_type_xy/public/utils/accessors.tsx b/src/plugins/vis_type_xy/public/utils/accessors.tsx index 0f73ebe7eed86..4920885f51a07 100644 --- a/src/plugins/vis_type_xy/public/utils/accessors.tsx +++ b/src/plugins/vis_type_xy/public/utils/accessors.tsx @@ -8,7 +8,8 @@ import { AccessorFn, Accessor } from '@elastic/charts'; import { BUCKET_TYPES } from '../../../data/public'; -import { FakeParams, Aspect } from '../types'; +import { FakeParams } from '../../../visualizations/public'; +import { Aspect } from '../types'; export const COMPLEX_X_ACCESSOR = '__customXAccessor__'; export const COMPLEX_SPLIT_ACCESSOR = '__complexSplitAccessor__'; diff --git a/src/plugins/vis_type_xy/public/utils/domain.ts b/src/plugins/vis_type_xy/public/utils/domain.ts index 9cd74cd0433cc..48527ec9333ed 100644 --- a/src/plugins/vis_type_xy/public/utils/domain.ts +++ b/src/plugins/vis_type_xy/public/utils/domain.ts @@ -13,8 +13,9 @@ import { DomainRange } from '@elastic/charts'; import { getAdjustedInterval } from '../../../charts/public'; import { Datatable } from '../../../expressions/public'; +import { DateHistogramParams, HistogramParams } from '../../../visualizations/public'; -import { Aspect, DateHistogramParams, HistogramParams } from '../types'; +import { Aspect } from '../types'; export const getXDomain = (params: Aspect['params']): DomainRange => { const minInterval = (params as DateHistogramParams | HistogramParams)?.interval ?? undefined; diff --git a/src/plugins/vis_type_xy/public/expression_functions/xy_dimension.ts b/src/plugins/visualizations/common/expression_functions/xy_dimension.ts similarity index 62% rename from src/plugins/vis_type_xy/public/expression_functions/xy_dimension.ts rename to src/plugins/visualizations/common/expression_functions/xy_dimension.ts index ecbc3640c035b..82538fea8605a 100644 --- a/src/plugins/vis_type_xy/public/expression_functions/xy_dimension.ts +++ b/src/plugins/visualizations/common/expression_functions/xy_dimension.ts @@ -7,13 +7,35 @@ */ import { i18n } from '@kbn/i18n'; -import type { ExpressionValueVisDimension } from '../../../visualizations/public'; +import type { ExpressionValueVisDimension } from './vis_dimension'; + import type { ExpressionFunctionDefinition, - Datatable, ExpressionValueBoxed, -} from '../../../expressions/public'; -import type { Dimension } from '../types'; + Datatable, + DatatableColumn, + SerializedFieldFormat, +} from '../../../expressions/common'; + +export interface DateHistogramParams { + date: boolean; + interval: number; + intervalESValue: number; + intervalESUnit: string; + format: string; + bounds?: { + min: string | number; + max: string | number; + }; +} + +export interface HistogramParams { + interval: number; +} + +export interface FakeParams { + defaultValue: string; +} interface Arguments { visDimension: ExpressionValueVisDimension; @@ -27,9 +49,9 @@ export type ExpressionValueXYDimension = ExpressionValueBoxed< { label: string; aggType: string; - params: Dimension['params']; - accessor: number; - format: Dimension['format']; + params: DateHistogramParams | HistogramParams | FakeParams | {}; + accessor: number | DatatableColumn; + format: SerializedFieldFormat; } >; @@ -40,34 +62,34 @@ export const xyDimension = (): ExpressionFunctionDefinition< ExpressionValueXYDimension > => ({ name: 'xydimension', - help: i18n.translate('visTypeXy.function.xydimension.help', { + help: i18n.translate('visualizations.function.xydimension.help', { defaultMessage: 'Generates xy dimension object', }), type: 'xy_dimension', args: { visDimension: { types: ['vis_dimension'], - help: i18n.translate('visTypeXy.function.xyDimension.visDimension.help', { + help: i18n.translate('visualizations.function.xyDimension.visDimension.help', { defaultMessage: 'Dimension object config', }), required: true, }, label: { types: ['string'], - help: i18n.translate('visTypeXy.function.xyDimension.label.help', { + help: i18n.translate('visualizations.function.xyDimension.label.help', { defaultMessage: 'Label', }), }, aggType: { types: ['string'], - help: i18n.translate('visTypeXy.function.xyDimension.aggType.help', { + help: i18n.translate('visualizations.function.xyDimension.aggType.help', { defaultMessage: 'Aggregation type', }), }, params: { types: ['string'], default: '"{}"', - help: i18n.translate('visTypeXy.function.xyDimension.params.help', { + help: i18n.translate('visualizations.function.xyDimension.params.help', { defaultMessage: 'Params', }), }, diff --git a/src/plugins/visualizations/common/prepare_log_table.ts b/src/plugins/visualizations/common/prepare_log_table.ts index f179eb8a1c10a..0018a18ce7f10 100644 --- a/src/plugins/visualizations/common/prepare_log_table.ts +++ b/src/plugins/visualizations/common/prepare_log_table.ts @@ -7,9 +7,13 @@ */ import { ExpressionValueVisDimension } from './expression_functions/vis_dimension'; +import { ExpressionValueXYDimension } from './expression_functions/xy_dimension'; import { Datatable } from '../../expressions/common/expression_types/specs'; -export type Dimension = [ExpressionValueVisDimension[] | undefined, string]; +export type Dimension = [ + Array | undefined, + string +]; const getDimensionName = (columnIndex: number, dimensions: Dimension[]) => { for (const dimension of dimensions) { diff --git a/src/plugins/visualizations/public/index.ts b/src/plugins/visualizations/public/index.ts index a01a2477dd311..0886f230d101f 100644 --- a/src/plugins/visualizations/public/index.ts +++ b/src/plugins/visualizations/public/index.ts @@ -41,5 +41,11 @@ export { } from './types'; export { VisualizationListItem, VisualizationStage } from './vis_types/vis_type_alias_registry'; export { VISUALIZE_ENABLE_LABS_SETTING } from '../common/constants'; -export { SavedVisState, VisParams, prepareLogTable } from '../common'; +export { SavedVisState, VisParams, prepareLogTable, Dimension } from '../common'; export { ExpressionValueVisDimension } from '../common/expression_functions/vis_dimension'; +export { + ExpressionValueXYDimension, + DateHistogramParams, + FakeParams, + HistogramParams, +} from '../common/expression_functions/xy_dimension'; diff --git a/src/plugins/visualizations/public/plugin.ts b/src/plugins/visualizations/public/plugin.ts index a890058aa7491..f5b2f0edd044e 100644 --- a/src/plugins/visualizations/public/plugin.ts +++ b/src/plugins/visualizations/public/plugin.ts @@ -33,6 +33,7 @@ import { import { TypesService } from './vis_types/types_service'; import { range as rangeExpressionFunction } from '../common/expression_functions/range'; import { visDimension as visDimensionExpressionFunction } from '../common/expression_functions/vis_dimension'; +import { xyDimension as xyDimensionExpressionFunction } from '../common/expression_functions/xy_dimension'; import { createStartServicesGetter, StartServicesGetter } from '../../kibana_utils/public'; import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visualizations'; @@ -138,6 +139,7 @@ export class VisualizationsPlugin expressions.registerFunction(rangeExpressionFunction); expressions.registerFunction(visDimensionExpressionFunction); + expressions.registerFunction(xyDimensionExpressionFunction); const embeddableFactory = new VisualizeEmbeddableFactory({ start }); embeddable.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index ae64dedfca5e4..54ef39a212fab 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5204,11 +5204,11 @@ "visTypeXy.function.valueAxis.axisParams.help": "値軸パラメーター", "visTypeXy.function.valueaxis.help": "値軸オブジェクトを生成します", "visTypeXy.function.valueAxis.name.help": "値軸の名前", - "visTypeXy.function.xyDimension.aggType.help": "集約タイプ", - "visTypeXy.function.xydimension.help": "XYディメンションオブジェクトを生成します", - "visTypeXy.function.xyDimension.label.help": "ラベル", - "visTypeXy.function.xyDimension.params.help": "パラメーター", - "visTypeXy.function.xyDimension.visDimension.help": "ディメンションオブジェクト構成", + "visualizations.function.xyDimension.aggType.help": "集約タイプ", + "visualizations.function.xydimension.help": "XYディメンションオブジェクトを生成します", + "visualizations.function.xyDimension.label.help": "ラベル", + "visualizations.function.xyDimension.params.help": "パラメーター", + "visualizations.function.xyDimension.visDimension.help": "ディメンションオブジェクト構成", "visTypeXy.functions.help": "XYビジュアライゼーション", "visTypeXy.histogram.groupTitle": "系列を分割", "visTypeXy.histogram.histogramDescription": "軸の縦棒にデータを表示します。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 2e73f4ce0a029..a30b5a9cb62e1 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5231,11 +5231,11 @@ "visTypeXy.function.valueAxis.axisParams.help": "值轴参数", "visTypeXy.function.valueaxis.help": "生成值轴对象", "visTypeXy.function.valueAxis.name.help": "值轴的名称", - "visTypeXy.function.xyDimension.aggType.help": "聚合类型", - "visTypeXy.function.xydimension.help": "生成 xy 维度对象", - "visTypeXy.function.xyDimension.label.help": "标签", - "visTypeXy.function.xyDimension.params.help": "参数", - "visTypeXy.function.xyDimension.visDimension.help": "维度对象配置", + "visualizations.function.xyDimension.aggType.help": "聚合类型", + "visualizations.function.xydimension.help": "生成 xy 维度对象", + "visualizations.function.xyDimension.label.help": "标签", + "visualizations.function.xyDimension.params.help": "参数", + "visualizations.function.xyDimension.visDimension.help": "维度对象配置", "visTypeXy.functions.help": "XY 可视化", "visTypeXy.histogram.groupTitle": "拆分序列", "visTypeXy.histogram.histogramDescription": "在轴上以垂直条形图的形式呈现数据。",