diff --git a/x-pack/plugins/lens/public/visualizations/partition/suggestions.ts b/x-pack/plugins/lens/public/visualizations/partition/suggestions.ts index eec86da39d606..0e66291c068da 100644 --- a/x-pack/plugins/lens/public/visualizations/partition/suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/partition/suggestions.ts @@ -239,12 +239,7 @@ export function suggestions({ ], }, previewIcon: PartitionChartsMeta.treemap.icon, - // hide treemap suggestions from bottom bar, but keep them for chart switcher - hide: - table.changeType === 'reduced' || - !state || - hasIntervalScale(groups) || - (state && state.shape === PieChartTypes.TREEMAP), + hide: table.changeType === 'reduced' || hasIntervalScale(groups), }); } @@ -292,11 +287,7 @@ export function suggestions({ ], }, previewIcon: PartitionChartsMeta.mosaic.icon, - hide: - groups.length !== 2 || - table.changeType === 'reduced' || - hasIntervalScale(groups) || - (state && state.shape === 'mosaic'), + hide: groups.length !== 2 || table.changeType === 'reduced' || hasIntervalScale(groups), }); } @@ -341,11 +332,7 @@ export function suggestions({ ], }, previewIcon: PartitionChartsMeta.waffle.icon, - hide: - groups.length !== 1 || - table.changeType === 'reduced' || - hasIntervalScale(groups) || - (state && state.shape === 'waffle'), + hide: groups.length !== 1 || table.changeType === 'reduced' || hasIntervalScale(groups), }); } @@ -359,7 +346,12 @@ export function suggestions({ .sort((a, b) => b.score - a.score) .map((suggestion) => ({ ...suggestion, - hide: shouldHideSuggestion || incompleteConfiguration || suggestion.hide, + hide: + // avoid to suggest the same shape if already used + (state && state.shape === suggestion.state.shape) || + shouldHideSuggestion || + incompleteConfiguration || + suggestion.hide, incomplete: incompleteConfiguration, })); } diff --git a/x-pack/test/functional/apps/lens/group1/smokescreen.ts b/x-pack/test/functional/apps/lens/group1/smokescreen.ts index e33e65741bf66..f482163930991 100644 --- a/x-pack/test/functional/apps/lens/group1/smokescreen.ts +++ b/x-pack/test/functional/apps/lens/group1/smokescreen.ts @@ -281,7 +281,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(data?.axes?.y?.[1].gridlines.length).to.eql(0); }); - it('should transition from a multi-layer stacked bar to donut chart using suggestions', async () => { + it('should transition from a multi-layer stacked bar to treemap chart using suggestions', async () => { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickVisType('lens'); await PageObjects.lens.goToTimeRange(); @@ -313,10 +313,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await PageObjects.lens.save('twolayerchart'); - await testSubjects.click('lnsSuggestion-donut > lnsSuggestion'); + await testSubjects.click('lnsSuggestion-treemap > lnsSuggestion'); expect(await PageObjects.lens.getLayerCount()).to.eql(1); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql( + expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_groupByDimensionPanel')).to.eql( 'Top 5 values of geo.dest' ); expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( diff --git a/x-pack/test_serverless/functional/test_suites/common/visualizations/group1/smokescreen.ts b/x-pack/test_serverless/functional/test_suites/common/visualizations/group1/smokescreen.ts index 5015b4be2250c..d4337d16db4ea 100644 --- a/x-pack/test_serverless/functional/test_suites/common/visualizations/group1/smokescreen.ts +++ b/x-pack/test_serverless/functional/test_suites/common/visualizations/group1/smokescreen.ts @@ -281,7 +281,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(data?.axes?.y?.[1].gridlines.length).to.eql(0); }); - it('should transition from a multi-layer stacked bar to donut chart using suggestions', async () => { + it('should transition from a multi-layer stacked bar to treemap chart using suggestions', async () => { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickVisType('lens'); await PageObjects.lens.goToTimeRange(); @@ -313,10 +313,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await PageObjects.lens.save('twolayerchart'); - await testSubjects.click('lnsSuggestion-donut > lnsSuggestion'); + await testSubjects.click('lnsSuggestion-treemap > lnsSuggestion'); expect(await PageObjects.lens.getLayerCount()).to.eql(1); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql( + expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_groupByDimensionPanel')).to.eql( 'Top 5 values of geo.dest' ); expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql(