Skip to content

Commit

Permalink
resolved 1 and 5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Nov 25, 2021
1 parent 1d8e18b commit 34f6cb6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { LensIconChartWaffle } from '../assets/chart_waffle';

import type { SharedPieLayerState } from '../../common/expressions';
import type { PieChartTypes } from '../../common/expressions/pie_chart/types';
import type { DatatableColumn } from '../../../../../src/plugins/expressions';

interface PartitionChartMeta {
icon: ({ title, titleId, ...props }: Omit<EuiIconProps, 'type'>) => JSX.Element;
Expand All @@ -34,9 +35,10 @@ interface PartitionChartMeta {
maxBuckets: number;
isExperimental?: boolean;
requiredMinDimensionCount?: number;
legend?: {
legend: {
flat?: boolean;
showValues?: boolean;
getShowLegendDefault?: (bucketColumns: DatatableColumn[]) => boolean;
};
}

Expand Down Expand Up @@ -112,6 +114,9 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
categoryOptions,
numberOptions,
maxBuckets: 3,
legend: {
getShowLegendDefault: (bucketColumns) => bucketColumns.length > 1,
},
},
pie: {
icon: LensIconChartPie,
Expand All @@ -123,6 +128,9 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
categoryOptions,
numberOptions,
maxBuckets: 3,
legend: {
getShowLegendDefault: (bucketColumns) => bucketColumns.length > 1,
},
},
treemap: {
icon: LensIconChartTreemap,
Expand All @@ -134,6 +142,9 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
categoryOptions: categoryOptionsTreemap,
numberOptions,
maxBuckets: 2,
legend: {
getShowLegendDefault: () => false,
},
},
mosaic: {
icon: LensIconChartMosaic,
Expand All @@ -147,6 +158,9 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
maxBuckets: 2,
isExperimental: true,
requiredMinDimensionCount: 2,
legend: {
getShowLegendDefault: () => false,
},
},
waffle: {
icon: LensIconChartWaffle,
Expand All @@ -162,6 +176,7 @@ export const PartitionChartsMeta: Record<PieChartTypes, PartitionChartMeta> = {
legend: {
flat: true,
showValues: true,
getShowLegendDefault: () => true,
},
},
};
13 changes: 7 additions & 6 deletions x-pack/plugins/lens/public/pie_visualization/render_function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ export function PieComponent(
};
});

const { legend, partitionType: partitionLayout, label: chartType } = PartitionChartsMeta[shape];

const config: RecursivePartial<PartitionConfig> = {
partitionLayout: PartitionChartsMeta[shape].partitionType,
partitionLayout,
fontFamily: chartTheme.barSeriesStyle?.displayValue?.fontFamily,
outerSizeRatio: 1,
specialFirstInnermostSector: true,
Expand Down Expand Up @@ -293,7 +295,7 @@ export function PieComponent(
id="xpack.lens.pie.pieWithNegativeWarningLabel"
defaultMessage="{chartType} charts can't render with negative values."
values={{
chartType: PartitionChartsMeta[shape].label,
chartType,
}}
/>
</EuiText>
Expand All @@ -320,11 +322,10 @@ export function PieComponent(
!hideLabels &&
(legendDisplay === 'show' ||
(legendDisplay === 'default' &&
bucketColumns.length > 1 &&
!isTreemapOrMosaicShape(shape)))
(legend.getShowLegendDefault?.(bucketColumns) ?? false)))
}
flatLegend={PartitionChartsMeta[shape].legend?.flat}
showLegendExtra={PartitionChartsMeta[shape].legend?.showValues}
flatLegend={legend.flat}
showLegendExtra={legend.showValues}
legendPosition={legendPosition || Position.Right}
legendMaxDepth={nestedLegend ? undefined : 1 /* Color is based only on first layer */}
onElementClick={props.interactive ?? true ? onElementClickHandler : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export const getPieVisualization = ({
if (
numericColumn &&
state.shape === 'waffle' &&
layer.groups.length &&
checkTableForContainsSmallValues(frame.activeData[layerId], numericColumn.id, 1)
) {
warningMessages.push(
Expand Down

0 comments on commit 34f6cb6

Please sign in to comment.