From e2ea2aa2cc8554f683dcf8410bd9d768ad0d651a Mon Sep 17 00:00:00 2001 From: Ashwin Pc Date: Fri, 9 Sep 2022 16:15:24 +0000 Subject: [PATCH] fixes time series for new chart types Signed-off-by: Ashwin Pc --- .../visualizations/vislib/area/to_expression.ts | 10 +++------- .../vislib/common/get_pipeline_params.ts | 16 ++++++++++++++++ .../public/visualizations/vislib/common/index.ts | 9 +++++++++ .../vislib/histogram/to_expression.ts | 10 +++------- .../visualizations/vislib/line/to_expression.ts | 10 +++------- 5 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 src/plugins/wizard/public/visualizations/vislib/common/get_pipeline_params.ts create mode 100644 src/plugins/wizard/public/visualizations/vislib/common/index.ts diff --git a/src/plugins/wizard/public/visualizations/vislib/area/to_expression.ts b/src/plugins/wizard/public/visualizations/vislib/area/to_expression.ts index 012c6589f57b..9d40d64c1cfc 100644 --- a/src/plugins/wizard/public/visualizations/vislib/area/to_expression.ts +++ b/src/plugins/wizard/public/visualizations/vislib/area/to_expression.ts @@ -7,8 +7,7 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public'; import { AreaOptionsDefaults } from './area_vis_type'; import { getAggExpressionFunctions } from '../../common/expression_helpers'; -import { VislibRootState } from '../common/types'; -import { getValueAxes } from '../common/get_value_axes'; +import { VislibRootState, getValueAxes, getPipelineParams } from '../common'; export const toExpression = async ({ style: styleState, @@ -16,15 +15,12 @@ export const toExpression = async ({ }: VislibRootState) => { const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization); const { addLegend, addTooltip, legendPosition, type } = styleState; - const pipelineConfigs = { - // todo: this will blow up for time x dimensions - timefilter: null, // todo: get the time filter from elsewhere - }; + const params = getPipelineParams(); const vis = new Vis(type); vis.data.aggs = aggConfigs; - const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any); + const dimensions = await buildVislibDimensions(vis, params); const valueAxes = getValueAxes(dimensions.y); // TODO: what do we want to put in this "vis config"? diff --git a/src/plugins/wizard/public/visualizations/vislib/common/get_pipeline_params.ts b/src/plugins/wizard/public/visualizations/vislib/common/get_pipeline_params.ts new file mode 100644 index 000000000000..8a4878e52850 --- /dev/null +++ b/src/plugins/wizard/public/visualizations/vislib/common/get_pipeline_params.ts @@ -0,0 +1,16 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BuildPipelineParams } from '../../../../../visualizations/public'; +import { getTimeFilter } from '../../../plugin_services'; + +export const getPipelineParams = (): BuildPipelineParams => { + const timeFilter = getTimeFilter(); + return { + // TODO: this will blow up for time x dimensions + timefilter: timeFilter, + timeRange: timeFilter.getTime(), + }; +}; diff --git a/src/plugins/wizard/public/visualizations/vislib/common/index.ts b/src/plugins/wizard/public/visualizations/vislib/common/index.ts new file mode 100644 index 000000000000..70614ce555eb --- /dev/null +++ b/src/plugins/wizard/public/visualizations/vislib/common/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export * from './basic_vis_options'; +export * from './get_pipeline_params'; +export * from './get_value_axes'; +export * from './types'; diff --git a/src/plugins/wizard/public/visualizations/vislib/histogram/to_expression.ts b/src/plugins/wizard/public/visualizations/vislib/histogram/to_expression.ts index 6b6f0fe30baf..6357b6acee22 100644 --- a/src/plugins/wizard/public/visualizations/vislib/histogram/to_expression.ts +++ b/src/plugins/wizard/public/visualizations/vislib/histogram/to_expression.ts @@ -7,8 +7,7 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public'; import { HistogramOptionsDefaults } from './histogram_vis_type'; import { getAggExpressionFunctions } from '../../common/expression_helpers'; -import { VislibRootState } from '../common/types'; -import { getValueAxes } from '../common/get_value_axes'; +import { VislibRootState, getValueAxes, getPipelineParams } from '../common'; export const toExpression = async ({ style: styleState, @@ -16,15 +15,12 @@ export const toExpression = async ({ }: VislibRootState) => { const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization); const { addLegend, addTooltip, legendPosition, type } = styleState; - const pipelineConfigs = { - // todo: this will blow up for time x dimensions - timefilter: null, // todo: get the time filter from elsewhere - }; + const params = getPipelineParams(); const vis = new Vis(type); vis.data.aggs = aggConfigs; - const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any); + const dimensions = await buildVislibDimensions(vis, params); const valueAxes = getValueAxes(dimensions.y); // TODO: what do we want to put in this "vis config"? diff --git a/src/plugins/wizard/public/visualizations/vislib/line/to_expression.ts b/src/plugins/wizard/public/visualizations/vislib/line/to_expression.ts index d7c7a13d2be7..32d40726bedf 100644 --- a/src/plugins/wizard/public/visualizations/vislib/line/to_expression.ts +++ b/src/plugins/wizard/public/visualizations/vislib/line/to_expression.ts @@ -7,8 +7,7 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public'; import { LineOptionsDefaults } from './line_vis_type'; import { getAggExpressionFunctions } from '../../common/expression_helpers'; -import { VislibRootState } from '../common/types'; -import { getValueAxes } from '../common/get_value_axes'; +import { VislibRootState, getValueAxes, getPipelineParams } from '../common'; export const toExpression = async ({ style: styleState, @@ -16,15 +15,12 @@ export const toExpression = async ({ }: VislibRootState) => { const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization); const { addLegend, addTooltip, legendPosition, type } = styleState; - const pipelineConfigs = { - // todo: this will blow up for time x dimensions - timefilter: null, // todo: get the time filter from elsewhere - }; + const params = getPipelineParams(); const vis = new Vis(type); vis.data.aggs = aggConfigs; - const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any); + const dimensions = await buildVislibDimensions(vis, params); const valueAxes = getValueAxes(dimensions.y); // TODO: what do we want to put in this "vis config"?