Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function WorkspacePanelWrapper({
clearStagedPreview: false,
});
},
[dispatch]
[dispatch, activeVisualization]
);
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { toExpression, toPreviewExpression } from './to_expression';
import { LayerState, PieVisualizationState } from './types';
import { suggestions } from './suggestions';
import { CHART_NAMES, MAX_PIE_BUCKETS, MAX_TREEMAP_BUCKETS } from './constants';
import { SettingsWidget } from './settings_widget';
import { PieToolbar } from './toolbar';

function newLayerState(layerId: string): LayerState {
return {
Expand Down Expand Up @@ -204,10 +204,10 @@ export const pieVisualization: Visualization<PieVisualizationState, PieVisualiza
toExpression,
toPreviewExpression,

renderLayerContextMenu(domElement, props) {
renderToolbar(domElement, props) {
render(
<I18nProvider>
<SettingsWidget {...props} />
<PieToolbar {...props} />
</I18nProvider>,
domElement
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { i18n } from '@kbn/i18n';
import { Position } from '@elastic/charts';
import { I18nProvider } from '@kbn/i18n/react';
import {
IInterpreterRenderHandlers,
Expand Down Expand Up @@ -73,6 +74,11 @@ export const pie: ExpressionFunctionDefinition<
types: ['boolean'],
help: '',
},
legendPosition: {
types: ['string'],
options: [Position.Top, Position.Right, Position.Bottom, Position.Left],
help: '',
},
percentDecimals: {
types: ['number'],
help: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ describe('PieVisualization component', () => {
};
}

test('it shows legend on correct side', () => {
const component = shallow(
<PieComponent args={{ ...args, legendPosition: 'top' }} {...getDefaultArgs()} />
);
expect(component.find(Settings).prop('legendPosition')).toEqual('top');
});

test('it shows legend for 2 groups using default legendDisplay', () => {
const component = shallow(<PieComponent args={args} {...getDefaultArgs()} />);
expect(component.find(Settings).prop('showLegend')).toEqual(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
PartitionFillLabel,
RecursivePartial,
LayerValue,
Position,
} from '@elastic/charts';
import { FormatFactory, LensFilterEvent } from '../types';
import { VisualizationContainer } from '../visualization_container';
Expand Down Expand Up @@ -55,6 +56,7 @@ export function PieComponent(
numberDisplay,
categoryDisplay,
legendDisplay,
legendPosition,
nestedLegend,
percentDecimals,
hideLabels,
Expand Down Expand Up @@ -237,6 +239,7 @@ export function PieComponent(
(legendDisplay === 'show' ||
(legendDisplay === 'default' && columnGroups.length > 1 && shape !== 'treemap'))
}
legendPosition={legendPosition || Position.Right}
legendMaxDepth={nestedLegend ? undefined : 1 /* Color is based only on first layer */}
onElementClick={(args) => {
const context = getFilterContext(
Expand Down

This file was deleted.

230 changes: 0 additions & 230 deletions x-pack/plugins/lens/public/pie_visualization/settings_widget.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function expressionHelper(
numberDisplay: [layer.numberDisplay],
categoryDisplay: [layer.categoryDisplay],
legendDisplay: [layer.legendDisplay],
legendPosition: [layer.legendPosition || 'right'],
percentDecimals: [layer.percentDecimals ?? DEFAULT_PERCENT_DECIMALS],
nestedLegend: [!!layer.nestedLegend],
},
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/lens/public/pie_visualization/toolbar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.lnsPieToolbar__popover {
width: $euiFormMaxWidth;
}
Loading