From b5a6d398cb353175ae794e4dd805ee7d33a50409 Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Tue, 31 Mar 2020 09:45:30 +0200 Subject: [PATCH] lens_min-interval-fix --- .../lens/public/xy_visualization/xy_expression.test.tsx | 2 +- .../lens/public/xy_visualization/xy_expression.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.test.tsx b/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.test.tsx index cdc5fc2ff1c17..d085fc7dac7f7 100644 --- a/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.test.tsx +++ b/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.test.tsx @@ -184,7 +184,7 @@ describe('xy_expression', () => { Object { "max": 1546491600000, "min": 1546405200000, - "minInterval": 10000, + "minInterval": undefined, } `); }); diff --git a/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx b/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx index a7d4b2a217f37..24646b5397623 100644 --- a/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx +++ b/x-pack/legacy/plugins/lens/public/xy_visualization/xy_expression.tsx @@ -211,14 +211,19 @@ export function XYChart({ const shouldRotate = isHorizontalChart(layers); const xTitle = (xAxisColumn && xAxisColumn.name) || args.xTitle; - const interval = parseInterval(xAxisColumn?.meta?.aggConfigParams?.interval); + + // add minInterval only for single row value as it cannot be determined from dataset + const minInterval = + data.tables[layers[0].layerId].rows.length === 1 + ? parseInterval(xAxisColumn?.meta?.aggConfigParams?.interval)?.asMilliseconds() + : undefined; const xDomain = data.dateRange && layers.every(l => l.xScaleType === 'time') ? { min: data.dateRange.fromDate.getTime(), max: data.dateRange.toDate.getTime(), - minInterval: interval?.asMilliseconds(), + minInterval, } : undefined; return (