Skip to content

Commit 5826ac4

Browse files
author
Wylie Conlon
authored
[Lens] Remove "inside only" option for treemap labels (#65363) (#65574)
* [Lens] Remove "inside only" option for treemap labels * Fix type error * Update from feedback
1 parent 8dd1fa5 commit 5826ac4

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

x-pack/plugins/lens/public/pie_visualization/render_function.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ export function PieComponent(
109109
return String(d);
110110
},
111111
fillLabel:
112-
isDarkMode && shape === 'treemap' && layerIndex < columnGroups.length - 1
112+
isDarkMode &&
113+
shape === 'treemap' &&
114+
layerIndex < columnGroups.length - 1 &&
115+
categoryDisplay !== 'hide'
113116
? { ...fillLabel, textColor: euiDarkVars.euiTextColor }
114117
: fillLabel,
115118
shape: {
@@ -252,6 +255,7 @@ export function PieComponent(
252255
valueFormatter={(d: number) => (hideLabels ? '' : formatters[metricColumn.id].convert(d))}
253256
layers={layers}
254257
config={config}
258+
topGroove={hideLabels || categoryDisplay === 'hide' ? 0 : undefined}
255259
/>
256260
</Chart>
257261
</VisualizationContainer>

x-pack/plugins/lens/public/pie_visualization/settings_widget.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ const categoryOptions: Array<{
6666
},
6767
];
6868

69+
const categoryOptionsTreemap: Array<{
70+
value: SharedLayerState['categoryDisplay'];
71+
inputDisplay: string;
72+
}> = [
73+
{
74+
value: 'default',
75+
inputDisplay: i18n.translate('xpack.lens.pieChart.showTreemapCategoriesLabel', {
76+
defaultMessage: 'Show labels',
77+
}),
78+
},
79+
{
80+
value: 'hide',
81+
inputDisplay: i18n.translate('xpack.lens.pieChart.categoriesInLegendLabel', {
82+
defaultMessage: 'Hide labels',
83+
}),
84+
},
85+
];
86+
6987
const legendOptions: Array<{
7088
value: SharedLayerState['legendDisplay'];
7189
label: string;
@@ -113,7 +131,7 @@ export function SettingsWidget(props: VisualizationLayerWidgetProps<PieVisualiza
113131
<EuiSuperSelect
114132
compressed
115133
valueOfSelected={layer.categoryDisplay}
116-
options={categoryOptions}
134+
options={state.shape === 'treemap' ? categoryOptionsTreemap : categoryOptions}
117135
onChange={option => {
118136
setState({
119137
...state,

x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ describe('suggestions', () => {
508508
metric: 'b',
509509

510510
numberDisplay: 'hidden',
511-
categoryDisplay: 'inside',
511+
categoryDisplay: 'default', // This is changed
512512
legendDisplay: 'show',
513513
percentDecimals: 0,
514514
nestedLegend: true,

x-pack/plugins/lens/public/pie_visualization/suggestions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export function suggestions({
115115
layerId: table.layerId,
116116
groups: groups.map(col => col.columnId),
117117
metric: metrics[0].columnId,
118+
categoryDisplay:
119+
state.layers[0].categoryDisplay === 'inside'
120+
? 'default'
121+
: state.layers[0].categoryDisplay,
118122
}
119123
: {
120124
layerId: table.layerId,

0 commit comments

Comments
 (0)