From 5826ac430f3c5bfad8d88d452fe774e306701ecd Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Wed, 6 May 2020 18:44:09 -0400 Subject: [PATCH] [Lens] Remove "inside only" option for treemap labels (#65363) (#65574) * [Lens] Remove "inside only" option for treemap labels * Fix type error * Update from feedback --- .../pie_visualization/render_function.tsx | 6 +++++- .../pie_visualization/settings_widget.tsx | 20 ++++++++++++++++++- .../pie_visualization/suggestions.test.ts | 2 +- .../public/pie_visualization/suggestions.ts | 4 ++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/lens/public/pie_visualization/render_function.tsx b/x-pack/plugins/lens/public/pie_visualization/render_function.tsx index f451a6b74e299..0c27a3e4b44e3 100644 --- a/x-pack/plugins/lens/public/pie_visualization/render_function.tsx +++ b/x-pack/plugins/lens/public/pie_visualization/render_function.tsx @@ -109,7 +109,10 @@ export function PieComponent( return String(d); }, fillLabel: - isDarkMode && shape === 'treemap' && layerIndex < columnGroups.length - 1 + isDarkMode && + shape === 'treemap' && + layerIndex < columnGroups.length - 1 && + categoryDisplay !== 'hide' ? { ...fillLabel, textColor: euiDarkVars.euiTextColor } : fillLabel, shape: { @@ -252,6 +255,7 @@ export function PieComponent( valueFormatter={(d: number) => (hideLabels ? '' : formatters[metricColumn.id].convert(d))} layers={layers} config={config} + topGroove={hideLabels || categoryDisplay === 'hide' ? 0 : undefined} /> diff --git a/x-pack/plugins/lens/public/pie_visualization/settings_widget.tsx b/x-pack/plugins/lens/public/pie_visualization/settings_widget.tsx index 5a02b91efc749..bb63ceceb2b1b 100644 --- a/x-pack/plugins/lens/public/pie_visualization/settings_widget.tsx +++ b/x-pack/plugins/lens/public/pie_visualization/settings_widget.tsx @@ -66,6 +66,24 @@ const categoryOptions: Array<{ }, ]; +const categoryOptionsTreemap: Array<{ + value: SharedLayerState['categoryDisplay']; + inputDisplay: string; +}> = [ + { + value: 'default', + inputDisplay: i18n.translate('xpack.lens.pieChart.showTreemapCategoriesLabel', { + defaultMessage: 'Show labels', + }), + }, + { + value: 'hide', + inputDisplay: i18n.translate('xpack.lens.pieChart.categoriesInLegendLabel', { + defaultMessage: 'Hide labels', + }), + }, +]; + const legendOptions: Array<{ value: SharedLayerState['legendDisplay']; label: string; @@ -113,7 +131,7 @@ export function SettingsWidget(props: VisualizationLayerWidgetProps { setState({ ...state, 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 7935d53f56845..20b267caa9074 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts +++ b/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts @@ -508,7 +508,7 @@ describe('suggestions', () => { metric: 'b', numberDisplay: 'hidden', - categoryDisplay: 'inside', + categoryDisplay: 'default', // This is changed legendDisplay: 'show', percentDecimals: 0, nestedLegend: true, diff --git a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts b/x-pack/plugins/lens/public/pie_visualization/suggestions.ts index e363cf922b356..16c8fda3807db 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts +++ b/x-pack/plugins/lens/public/pie_visualization/suggestions.ts @@ -115,6 +115,10 @@ export function suggestions({ layerId: table.layerId, groups: groups.map(col => col.columnId), metric: metrics[0].columnId, + categoryDisplay: + state.layers[0].categoryDisplay === 'inside' + ? 'default' + : state.layers[0].categoryDisplay, } : { layerId: table.layerId,