diff --git a/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts b/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts index 92dde282da502..a2e3f6d3ca865 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts +++ b/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts @@ -784,7 +784,7 @@ describe('suggestions', () => { ).toHaveLength(0); }); - it('mosaic type should be added only in case of 2 groups', () => { + it('mosaic type should be hidden from the suggestion list', () => { expect( suggestions({ table: { @@ -827,97 +827,6 @@ describe('suggestions', () => { }, keptLayerIds: ['first'], }).filter(({ hide, state }) => !hide && state.shape === 'mosaic') - ).toMatchInlineSnapshot(` - Array [ - Object { - "hide": false, - "previewIcon": "bullseye", - "score": 0.6, - "state": Object { - "layers": Array [ - Object { - "categoryDisplay": "default", - "groups": Array [ - "a", - "b", - ], - "layerId": "first", - "layerType": "data", - "legendDisplay": "show", - "legendMaxLines": 1, - "metric": "c", - "nestedLegend": true, - "numberDisplay": "hidden", - "percentDecimals": 0, - "truncateLegend": true, - }, - ], - "palette": undefined, - "shape": "mosaic", - }, - "title": "As Mosaic", - }, - ] - `); - }); - - it('mosaic type should be added only in case of 2 groups (negative test)', () => { - const meta: Parameters[0] = { - table: { - layerId: 'first', - isMultiRow: true, - columns: [ - { - columnId: 'a', - operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true }, - }, - { - columnId: 'c', - operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false }, - }, - ], - changeType: 'unchanged', - }, - state: { - shape: 'pie', - layers: [ - { - layerId: 'first', - layerType: layerTypes.DATA, - groups: ['a', 'b'], - metric: 'c', - - numberDisplay: 'hidden', - categoryDisplay: 'inside', - legendDisplay: 'show', - percentDecimals: 0, - legendMaxLines: 1, - truncateLegend: true, - nestedLegend: true, - }, - ], - }, - keptLayerIds: ['first'], - }; - - // test with 1 group - expect( - suggestions(meta).filter(({ hide, state }) => !hide && state.shape === 'mosaic') - ).toMatchInlineSnapshot(`Array []`); - - meta.table.columns.push({ - columnId: 'b', - operation: { label: 'Top 6', dataType: 'string' as DataType, isBucketed: true }, - }); - - meta.table.columns.push({ - columnId: 'c', - operation: { label: 'Top 7', dataType: 'string' as DataType, isBucketed: true }, - }); - - // test with 3 groups - expect( - suggestions(meta).filter(({ hide, state }) => !hide && state.shape === 'mosaic') ).toMatchInlineSnapshot(`Array []`); }); }); @@ -952,7 +861,7 @@ describe('suggestions', () => { ).toHaveLength(0); }); - it('waffle type should be added only in case of 1 group', () => { + it('waffle type should be hidden from the suggestion list', () => { expect( suggestions({ table: { @@ -971,14 +880,13 @@ describe('suggestions', () => { changeType: 'unchanged', }, state: { - shape: 'waffle', + shape: 'pie', layers: [ { layerId: 'first', layerType: layerTypes.DATA, groups: ['a', 'b'], metric: 'c', - numberDisplay: 'hidden', categoryDisplay: 'inside', legendDisplay: 'show', @@ -993,61 +901,5 @@ describe('suggestions', () => { }).filter(({ hide, state }) => !hide && state.shape === 'waffle') ).toMatchInlineSnapshot(`Array []`); }); - - it('waffle type should be added only in case of 1 group (negative test)', () => { - const meta: Parameters[0] = { - table: { - layerId: 'first', - isMultiRow: true, - columns: [ - { - columnId: 'c', - operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false }, - }, - ], - changeType: 'unchanged', - }, - state: { - shape: 'pie', - layers: [ - { - layerId: 'first', - layerType: layerTypes.DATA, - groups: ['a', 'b'], - metric: 'c', - - numberDisplay: 'hidden', - categoryDisplay: 'inside', - legendDisplay: 'show', - percentDecimals: 0, - legendMaxLines: 1, - truncateLegend: true, - nestedLegend: true, - }, - ], - }, - keptLayerIds: ['first'], - }; - - // test with no group - expect( - suggestions(meta).filter(({ hide, state }) => !hide && state.shape === 'waffle') - ).toMatchInlineSnapshot(`Array []`); - - meta.table.columns.push({ - columnId: 'b', - operation: { label: 'Top 6', dataType: 'string' as DataType, isBucketed: true }, - }); - - meta.table.columns.push({ - columnId: 'c', - operation: { label: 'Top 7', dataType: 'string' as DataType, isBucketed: true }, - }); - - // test with 2 groups - expect( - suggestions(meta).filter(({ hide, state }) => !hide && state.shape === 'waffle') - ).toMatchInlineSnapshot(`Array []`); - }); }); }); diff --git a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts b/x-pack/plugins/lens/public/pie_visualization/suggestions.ts index f638bfd908be4..248f4a82b1694 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts +++ b/x-pack/plugins/lens/public/pie_visualization/suggestions.ts @@ -232,11 +232,7 @@ export function suggestions({ ], }, previewIcon: 'bullseye', - hide: - groups.length !== 2 || - table.changeType === 'reduced' || - hasIntervalScale(groups) || - (state && state.shape === 'mosaic'), + hide: true, }); } @@ -275,11 +271,7 @@ export function suggestions({ ], }, previewIcon: 'bullseye', - hide: - groups.length !== 1 || - table.changeType === 'reduced' || - hasIntervalScale(groups) || - (state && state.shape === 'waffle'), + hide: true, }); }