diff --git a/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx b/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx index 7d139aed225d3..0ba29502cf280 100644 --- a/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/partition/visualization.tsx @@ -24,6 +24,7 @@ import type { VisualizationDimensionGroupConfig, Suggestion, VisualizeEditorContext, + VisualizationInfo, } from '../../types'; import { getSortedGroups, toExpression, toPreviewExpression } from './to_expression'; import { @@ -40,6 +41,10 @@ import { DimensionDataExtraEditor, DimensionEditor, PieToolbar } from './toolbar import { LayerSettings } from './layer_settings'; import { checkTableForContainsSmallValues } from './render_helpers'; +const metricLabel = i18n.translate('xpack.lens.pie.groupMetricLabelSingular', { + defaultMessage: 'Metric', +}); + function newLayerState(layerId: string): PieLayerState { return { layerId, @@ -299,9 +304,7 @@ export const getPieVisualization = ({ ? i18n.translate('xpack.lens.pie.groupMetricLabel', { defaultMessage: 'Metrics', }) - : i18n.translate('xpack.lens.pie.groupMetricLabelSingular', { - defaultMessage: 'Metric', - }); + : metricLabel; return { groupId: 'metric', @@ -581,15 +584,14 @@ export const getPieVisualization = ({ getVisualizationInfo(state: PieVisualizationState) { const layer = state.layers[0]; - const dimensions = []; - if (layer.metric) { + const dimensions: VisualizationInfo['layers'][number]['dimensions'] = []; + + layer.metrics.forEach((metric) => { dimensions.push({ - id: layer.metric, - name: i18n.translate('xpack.lens.pie.groupsizeLabel', { - defaultMessage: 'Size by', - }), + id: metric, + name: metricLabel, }); - } + }); if (state.shape === 'mosaic' && layer.secondaryGroups && layer.secondaryGroups.length) { layer.secondaryGroups.forEach((accessor) => {