From e557ac64640770364d2ced6a01731eca41d1c84f Mon Sep 17 00:00:00 2001 From: Uladzislau Lasitsa Date: Mon, 21 Mar 2022 16:42:03 +0300 Subject: [PATCH] Add interval arg --- .../expression_xy/common/expression_functions/xy_vis.ts | 6 ++++++ .../expression_xy/common/types/expression_functions.ts | 1 + .../expression_xy/public/helpers/interval.ts | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis.ts b/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis.ts index 8049d117b3389..8d4dbb0dd1b52 100644 --- a/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis.ts +++ b/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis.ts @@ -166,6 +166,12 @@ export const xyVisFunction: ExpressionFunctionDefinition< defaultMessage: 'Show values in legend', }), }, + interval: { + types: ['number'], + help: i18n.translate('expressionXY.xyVis.interval.help', { + defaultMessage: 'Specifies the interval for x-axis in milliseconds', + }), + }, ariaLabel: { types: ['string'], help: i18n.translate('expressionXY.xyVis.ariaLabel.help', { diff --git a/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts b/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts index 2fee0b418d642..fd8a811825af8 100644 --- a/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts +++ b/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts @@ -174,6 +174,7 @@ export interface XYArgs { hideEndzones?: boolean; valuesInLegend?: boolean; ariaLabel?: string; + interval?: number; } export interface XYReferenceLineLayerConfig { diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/interval.ts b/src/plugins/chart_expressions/expression_xy/public/helpers/interval.ts index 7e15b49c311d4..933ffdd8532ec 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/interval.ts +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/interval.ts @@ -11,7 +11,7 @@ import { XYChartProps } from '../../common'; import { getFilteredLayers } from './layers'; import { isDataLayer } from './visualization'; -export function calculateMinInterval({ args: { layers }, data }: XYChartProps) { +export function calculateMinInterval({ args: { layers, interval }, data }: XYChartProps) { const filteredLayers = getFilteredLayers(layers, data); if (filteredLayers.length === 0) return; const isTimeViz = filteredLayers.every((l) => isDataLayer(l) && l.xScaleType === 'time'); @@ -20,6 +20,9 @@ export function calculateMinInterval({ args: { layers }, data }: XYChartProps) { ); if (!xColumn) return; + if (interval) { + return interval; + } if (!isTimeViz) { const histogramInterval = search.aggs.getNumberHistogramIntervalByDatatableColumn(xColumn); if (typeof histogramInterval === 'number') {