From 33ee2beb9d0f04a346a2d1b8ca1e0c6d747f6c27 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Thu, 25 Nov 2021 17:54:23 +0300 Subject: [PATCH] resolved 6 --- .../partition_charts_meta.ts | 58 ++++++++++++------- .../public/pie_visualization/to_expression.ts | 6 +- .../lens/public/pie_visualization/toolbar.tsx | 7 ++- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts b/x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts index caeffa5250784..932b9e9500090 100644 --- a/x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts +++ b/x-pack/plugins/lens/public/pie_visualization/partition_charts_meta.ts @@ -24,17 +24,20 @@ interface PartitionChartMeta { label: string; partitionType: PartitionLayout; groupLabel: string; - categoryOptions: Array<{ - value: SharedPieLayerState['categoryDisplay']; - inputDisplay: string; - }>; - numberOptions: Array<{ - value: SharedPieLayerState['numberDisplay']; - inputDisplay: string; - }>; maxBuckets: number; isExperimental?: boolean; requiredMinDimensionCount?: number; + toolbarPopover: { + isDisabled?: boolean; + categoryOptions: Array<{ + value: SharedPieLayerState['categoryDisplay']; + inputDisplay: string; + }>; + numberOptions: Array<{ + value: SharedPieLayerState['numberDisplay']; + inputDisplay: string; + }>; + }; legend: { flat?: boolean; showValues?: boolean; @@ -46,7 +49,7 @@ const groupLabel = i18n.translate('xpack.lens.pie.groupLabel', { defaultMessage: 'Proportion', }); -const categoryOptions: PartitionChartMeta['categoryOptions'] = [ +const categoryOptions: PartitionChartMeta['toolbarPopover']['categoryOptions'] = [ { value: 'default', inputDisplay: i18n.translate('xpack.lens.pieChart.showCategoriesLabel', { @@ -67,7 +70,7 @@ const categoryOptions: PartitionChartMeta['categoryOptions'] = [ }, ]; -const categoryOptionsTreemap: PartitionChartMeta['categoryOptions'] = [ +const categoryOptionsTreemap: PartitionChartMeta['toolbarPopover']['categoryOptions'] = [ { value: 'default', inputDisplay: i18n.translate('xpack.lens.pieChart.showTreemapCategoriesLabel', { @@ -82,7 +85,7 @@ const categoryOptionsTreemap: PartitionChartMeta['categoryOptions'] = [ }, ]; -const numberOptions: PartitionChartMeta['numberOptions'] = [ +const numberOptions: PartitionChartMeta['toolbarPopover']['numberOptions'] = [ { value: 'hidden', inputDisplay: i18n.translate('xpack.lens.pieChart.hiddenNumbersLabel', { @@ -111,9 +114,11 @@ export const PartitionChartsMeta: Record = { }), partitionType: PartitionLayout.sunburst, groupLabel, - categoryOptions, - numberOptions, maxBuckets: 3, + toolbarPopover: { + categoryOptions, + numberOptions, + }, legend: { getShowLegendDefault: (bucketColumns) => bucketColumns.length > 1, }, @@ -125,9 +130,11 @@ export const PartitionChartsMeta: Record = { }), partitionType: PartitionLayout.sunburst, groupLabel, - categoryOptions, - numberOptions, maxBuckets: 3, + toolbarPopover: { + categoryOptions, + numberOptions, + }, legend: { getShowLegendDefault: (bucketColumns) => bucketColumns.length > 1, }, @@ -139,9 +146,11 @@ export const PartitionChartsMeta: Record = { }), partitionType: PartitionLayout.treemap, groupLabel, - categoryOptions: categoryOptionsTreemap, - numberOptions, maxBuckets: 2, + toolbarPopover: { + categoryOptions: categoryOptionsTreemap, + numberOptions, + }, legend: { getShowLegendDefault: () => false, }, @@ -153,14 +162,16 @@ export const PartitionChartsMeta: Record = { }), partitionType: PartitionLayout.mosaic, groupLabel, - categoryOptions: [], - numberOptions, maxBuckets: 2, isExperimental: true, - requiredMinDimensionCount: 2, + toolbarPopover: { + categoryOptions: [], + numberOptions, + }, legend: { getShowLegendDefault: () => false, }, + requiredMinDimensionCount: 2, }, waffle: { icon: LensIconChartWaffle, @@ -169,10 +180,13 @@ export const PartitionChartsMeta: Record = { }), partitionType: PartitionLayout.waffle, groupLabel, - categoryOptions: [], - numberOptions: [], maxBuckets: 1, isExperimental: true, + toolbarPopover: { + isDisabled: true, + categoryOptions: [], + numberOptions: [], + }, legend: { flat: true, showValues: true, diff --git a/x-pack/plugins/lens/public/pie_visualization/to_expression.ts b/x-pack/plugins/lens/public/pie_visualization/to_expression.ts index fd754906ceb02..e13fbf62708ee 100644 --- a/x-pack/plugins/lens/public/pie_visualization/to_expression.ts +++ b/x-pack/plugins/lens/public/pie_visualization/to_expression.ts @@ -55,7 +55,11 @@ function expressionHelper( categoryDisplay: [layer.categoryDisplay], legendDisplay: [layer.legendDisplay], legendPosition: [layer.legendPosition || 'right'], - percentDecimals: [layer.percentDecimals ?? DEFAULT_PERCENT_DECIMALS], + percentDecimals: [ + state.shape === 'waffle' + ? DEFAULT_PERCENT_DECIMALS + : layer.percentDecimals ?? DEFAULT_PERCENT_DECIMALS, + ], legendMaxLines: [layer.legendMaxLines ?? 1], truncateLegend: [layer.truncateLegend ?? true], nestedLegend: [!!layer.nestedLegend], diff --git a/x-pack/plugins/lens/public/pie_visualization/toolbar.tsx b/x-pack/plugins/lens/public/pie_visualization/toolbar.tsx index 7bb7da9b3223e..195a72cca9fed 100644 --- a/x-pack/plugins/lens/public/pie_visualization/toolbar.tsx +++ b/x-pack/plugins/lens/public/pie_visualization/toolbar.tsx @@ -58,7 +58,11 @@ export function PieToolbar(props: VisualizationToolbarProps @@ -66,6 +70,7 @@ export function PieToolbar(props: VisualizationToolbarProps