Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Dec 7, 2021
1 parent 16cc7bc commit 8a8e5ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions x-pack/plugins/lens/public/pie_visualization/render_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ export const isPartitionShape = (shape: PieChartTypes | string) =>
export const isTreemapOrMosaicShape = (shape: PieChartTypes | string) =>
['treemap', 'mosaic'].includes(shape);

export const shouldShowValuesInLegend = (layer: PieLayerState, shape: PieChartTypes) =>
layer.showValuesInLegend !== undefined
? layer.showValuesInLegend
: Boolean(PartitionChartsMeta[shape]?.legend?.showValues);
export const shouldShowValuesInLegend = (layer: PieLayerState, shape: PieChartTypes) => {
if ('showValues' in PartitionChartsMeta[shape]?.legend) {
return layer.showValuesInLegend ?? PartitionChartsMeta[shape]?.legend?.showValues ?? true;
}

return false;
};

export const extractUniqTermsMap = (dataTable: Datatable, columnId: string) =>
[...new Set(dataTable.rows.map((item) => item[columnId]))].reduce(
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/lens/public/pie_visualization/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ export function PieToolbar(props: VisualizationToolbarProps<PieVisualizationStat
mode={layer.legendDisplay}
onDisplayChange={onLegendDisplayChange}
valueInLegend={shouldShowValuesInLegend(layer, state.shape)}
renderValueInLegendSwitch={Boolean(PartitionChartsMeta[state.shape]?.legend?.showValues)}
renderValueInLegendSwitch={
'showValues' in PartitionChartsMeta[state.shape]?.legend ?? false
}
onValueInLegendChange={onValueInLegendChange}
position={layer.legendPosition}
onPositionChange={onLegendPositionChange}
Expand Down

0 comments on commit 8a8e5ed

Please sign in to comment.