diff --git a/src/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts b/src/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts index 2bff967c09829..62d2212587a1e 100644 --- a/src/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts +++ b/src/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts @@ -49,7 +49,7 @@ interface Schemas { [key: string]: any[] | undefined; } -type buildVisFunction = (visState: VisState, schemas: Schemas) => string; +type buildVisFunction = (visState: VisState, schemas: Schemas, uiState: any) => string; interface BuildPipelineVisFunction { [key: string]: buildVisFunction; @@ -201,8 +201,11 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = { input_control_vis: visState => { return `input_control_vis ${prepareJson('visConfig', visState.params)}`; }, - metrics: visState => { - return `tsvb ${prepareJson('params', visState.params)}`; + metrics: (visState, schemas, uiState) => { + const params = prepareJson('params', visState.params); + const uiState = prepareJson('uiState', uiState); + + return `tsvb ${params} ${uiState}`; }, timelion: visState => { const expression = prepareString('expression', visState.params.expression); @@ -300,6 +303,7 @@ export const buildPipeline = ( const query = searchSource.getField('query'); const filters = searchSource.getField('filter'); const visState = vis.getCurrentState(); + const uiState = vis.getUiState(); // context let pipeline = `kibana | kibana_context `; @@ -325,7 +329,7 @@ export const buildPipeline = ( const schemas = getSchemas(vis, params.timeRange); if (buildPipelineVisFunction[vis.type.name]) { - pipeline += buildPipelineVisFunction[vis.type.name](visState, schemas); + pipeline += buildPipelineVisFunction[vis.type.name](visState, schemas, uiState); } else if (vislibCharts.includes(vis.type.name)) { const visConfig = visState.params; visConfig.dimensions = buildVislibDimensions(vis, params.timeRange);