Skip to content

Commit

Permalink
resolved 6
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Nov 25, 2021
1 parent 34f6cb6 commit 33ee2be
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand Down Expand Up @@ -111,9 +114,11 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
}),
partitionType: PartitionLayout.sunburst,
groupLabel,
categoryOptions,
numberOptions,
maxBuckets: 3,
toolbarPopover: {
categoryOptions,
numberOptions,
},
legend: {
getShowLegendDefault: (bucketColumns) => bucketColumns.length > 1,
},
Expand All @@ -125,9 +130,11 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
}),
partitionType: PartitionLayout.sunburst,
groupLabel,
categoryOptions,
numberOptions,
maxBuckets: 3,
toolbarPopover: {
categoryOptions,
numberOptions,
},
legend: {
getShowLegendDefault: (bucketColumns) => bucketColumns.length > 1,
},
Expand All @@ -139,9 +146,11 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
}),
partitionType: PartitionLayout.treemap,
groupLabel,
categoryOptions: categoryOptionsTreemap,
numberOptions,
maxBuckets: 2,
toolbarPopover: {
categoryOptions: categoryOptionsTreemap,
numberOptions,
},
legend: {
getShowLegendDefault: () => false,
},
Expand All @@ -153,14 +162,16 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
}),
partitionType: PartitionLayout.mosaic,
groupLabel,
categoryOptions: [],
numberOptions,
maxBuckets: 2,
isExperimental: true,
requiredMinDimensionCount: 2,
toolbarPopover: {
categoryOptions: [],
numberOptions,
},
legend: {
getShowLegendDefault: () => false,
},
requiredMinDimensionCount: 2,
},
waffle: {
icon: LensIconChartWaffle,
Expand All @@ -169,10 +180,13 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
}),
partitionType: PartitionLayout.waffle,
groupLabel,
categoryOptions: [],
numberOptions: [],
maxBuckets: 1,
isExperimental: true,
toolbarPopover: {
isDisabled: true,
categoryOptions: [],
numberOptions: [],
},
legend: {
flat: true,
showValues: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/lens/public/pie_visualization/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,19 @@ export function PieToolbar(props: VisualizationToolbarProps<PieVisualizationStat
if (!layer) {
return null;
}
const { categoryOptions, numberOptions } = PartitionChartsMeta[state.shape];
const {
categoryOptions,
numberOptions,
isDisabled: isToolbarPopoverDisabled,
} = PartitionChartsMeta[state.shape].toolbarPopover;

return (
<EuiFlexGroup gutterSize="none" justifyContent="spaceBetween" responsive={false}>
<ToolbarPopover
title={i18n.translate('xpack.lens.pieChart.valuesLabel', {
defaultMessage: 'Labels',
})}
isDisabled={Boolean(isToolbarPopoverDisabled)}
type="labels"
groupPosition="left"
buttonDataTestSubj="lnsLabelsButton"
Expand Down

0 comments on commit 33ee2be

Please sign in to comment.