From d1171418dd7d8c7252ad34b6bb2e4ff505fb684d Mon Sep 17 00:00:00 2001 From: Marta Bondyra <4283304+mbondyra@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:25:07 +0100 Subject: [PATCH] [Lens] revert Select line chart by default if the x-axis contains a timestamp (#198555) Reverts https://github.com/elastic/kibana/pull/190786/files --------- Co-authored-by: Marco Vettorello --- .../lens/public/visualizations/xy/xy_suggestions.test.ts | 6 +++--- .../plugins/lens/public/visualizations/xy/xy_suggestions.ts | 3 --- .../test/functional/apps/lens/group1/multiple_data_views.ts | 6 +++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.test.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.test.ts index 7ce86ed903065..113df3cf7622a 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.test.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.test.ts @@ -854,7 +854,7 @@ describe('xy_suggestions', () => { expect((suggestions[0].state.layers[0] as XYDataLayerConfig).seriesType).toEqual('line'); }); - test('suggests line if changeType is initial and date column is involved', () => { + test('suggests bar if changeType is initial and date column is involved', () => { const currentState: XYState = { legend: { isVisible: true, position: 'bottom' }, valueLabels: 'hide', @@ -885,8 +885,8 @@ describe('xy_suggestions', () => { expect(suggestions).toHaveLength(1); expect(suggestions[0].hide).toEqual(false); - expect(suggestions[0].state.preferredSeriesType).toEqual('line'); - expect((suggestions[0].state.layers[0] as XYDataLayerConfig).seriesType).toEqual('line'); + expect(suggestions[0].state.preferredSeriesType).toEqual('bar_stacked'); + expect((suggestions[0].state.layers[0] as XYDataLayerConfig).seriesType).toEqual('bar_stacked'); }); test('makes a visible seriesType suggestion for unchanged table without split', () => { diff --git a/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.ts b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.ts index 5efaf4d8c949e..f13bcc57e3c84 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/xy/xy_suggestions.ts @@ -233,9 +233,6 @@ function getSuggestionsForLayer({ allowMixed, }; - if (changeType === 'initial' && xValue?.operation.dataType === 'date') { - return buildSuggestion({ ...options, seriesType: 'line' }); - } // handles the simplest cases, acting as a chart switcher if (!currentState && changeType === 'unchanged') { // Chart switcher needs to include every chart type diff --git a/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts b/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts index d65b10d0056e1..0164aa745fc8e 100644 --- a/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts +++ b/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts @@ -103,13 +103,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('fieldToggle-DistanceKilometers'); const data = await lens.getCurrentChartDebugState('xyVisChart'); - assertMatchesExpectedData(data, [expectedLogstashData, expectedFlightsData], 'lines'); + assertMatchesExpectedData(data, [expectedLogstashData, expectedFlightsData]); }); it('ignores global filters on layers using a data view without the filter field', async () => { await filterBar.addFilter({ field: 'Carrier', operation: 'exists' }); const data = await lens.getCurrentChartDebugState('xyVisChart'); - assertMatchesExpectedData(data, [expectedLogstashData, expectedFlightsData], 'lines'); + assertMatchesExpectedData(data, [expectedLogstashData, expectedFlightsData]); await lens.save(visTitle); }); @@ -120,7 +120,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await visualize.openSavedVisualization(visTitle); const data = await lens.getCurrentChartDebugState('xyVisChart'); - assertMatchesExpectedData(data, [expectedFlightsData], 'lines'); + assertMatchesExpectedData(data, [expectedFlightsData]); }); }); }