Skip to content

Commit 603d533

Browse files
liuzhenyingaiyin.lzy
and
aiyin.lzy
authored
fix: 修复尖底漏斗图最后一排错位 (#2793)
* feat: 更新漏斗图默认 layout.type * fix: 修复尖底漏斗图错位&增加注释 Co-authored-by: aiyin.lzy <[email protected]>
1 parent 2dc2d96 commit 603d533

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

__tests__/unit/plots/funnel/basic-spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ describe('basic funnel', () => {
7171
});
7272
});
7373

74+
describe('pyramid', () => {
75+
test('transpose', () => {
76+
funnel.update({
77+
...funnelOption,
78+
shape: 'pyramid',
79+
});
80+
81+
const geometry = funnel.chart.geometries[0];
82+
expect(geometry.labelOption.cfg.layout.type).toBe('interval-adjust-position');
83+
const shapeFields = geometry.getAttribute('shape').getFields();
84+
expect(shapeFields[0]).toBe('pyramid');
85+
});
86+
});
87+
7488
describe('transpose', () => {
7589
test('transpose', () => {
7690
funnel.update({

src/plots/funnel/geometries/basic.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Types } from '@antv/g2';
22
import { isArray } from '@antv/util';
3-
import { flow, findGeometry } from '../../../utils';
3+
import { flow, findGeometry, deepAssign } from '../../../utils';
44
import { getTooltipMapping } from '../../../utils/tooltip';
55
import { Params } from '../../../core/adaptor';
66
import { Datum, Data } from '../../../types/common';
@@ -51,7 +51,15 @@ function geometry(params: Params<FunnelOptions>): Params<FunnelOptions> {
5151
color,
5252
style: funnelStyle,
5353
},
54-
label,
54+
// 使用 Interval 绘制的漏斗图,默认使用 'interval-adjust-position', 否则尖底漏斗图最后一行 label 错位
55+
label: deepAssign(
56+
{
57+
layout: {
58+
type: 'interval-adjust-position',
59+
},
60+
},
61+
label
62+
),
5563
state,
5664
},
5765
});

0 commit comments

Comments
 (0)