Skip to content

Commit 4872adb

Browse files
committed
fix: 优化重复代码
1 parent 0b52196 commit 4872adb

File tree

1 file changed

+0
-60
lines changed

1 file changed

+0
-60
lines changed

packages/f2/src/components/legend/withLegend.tsx

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -215,66 +215,6 @@ export default (View) => {
215215
this.legendStyle = style;
216216
}
217217

218-
_adaptiveLayout(node) {
219-
const { props, context } = this;
220-
const {
221-
// @ts-ignore
222-
layout: parentLayout,
223-
width: customWidth,
224-
height: customHeight,
225-
position = 'top',
226-
} = props;
227-
const items = this.getItems();
228-
if (!items || !items.length) return;
229-
const { left, top, width: layoutWidth, height: layoutHeight } = parentLayout;
230-
const width = context.px2hd(customWidth) || layoutWidth;
231-
232-
const { width: itemMaxWidth, height: itemMaxHeight } = this.getMaxItemBox(node);
233-
234-
const lineCount = 1; // 先不考虑多行的情况
235-
236-
const autoHeight = itemMaxHeight * lineCount;
237-
const style: GroupStyleProps = {
238-
left,
239-
top,
240-
width,
241-
// height 默认自适应
242-
height: undefined,
243-
flexDirection: 'row',
244-
flexWrap: 'wrap',
245-
alignItems: 'center',
246-
justifyContent: 'flex-start',
247-
};
248-
// 如果只有一行,2端对齐
249-
if (lineCount === 1) {
250-
style.justifyContent = 'space-between';
251-
}
252-
if (position === 'top') {
253-
style.height = customHeight ? customHeight : autoHeight;
254-
}
255-
if (position === 'left') {
256-
style.flexDirection = 'column';
257-
style.justifyContent = 'center';
258-
style.alignItems = 'flex-start';
259-
style.width = itemMaxWidth;
260-
style.height = customHeight ? customHeight : layoutHeight;
261-
}
262-
if (position === 'right') {
263-
style.flexDirection = 'column';
264-
style.alignItems = 'flex-start';
265-
style.justifyContent = 'center';
266-
style.left = left + (width - itemMaxWidth);
267-
style.width = itemMaxWidth;
268-
style.height = customHeight ? customHeight : layoutHeight;
269-
}
270-
if (position === 'bottom') {
271-
style.top = top + (layoutHeight - autoHeight);
272-
style.height = customHeight ? customHeight : autoHeight;
273-
}
274-
275-
this.legendStyle = style;
276-
}
277-
278218
updateCoord() {
279219
const { context, props, legendStyle } = this;
280220
const { position = 'top', margin = '30px', chart } = props;

0 commit comments

Comments
 (0)