Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(funnel): annotation 位置添加center,支持在漏斗图中正常显示 #3611

Merged
merged 2 commits into from
Sep 10, 2021
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
2 changes: 1 addition & 1 deletion examples/funnel/funnel/demo/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ chart.on('beforepaint', () => {
top: true,
position: {
action: obj.action,
percent: 'median',
percent: 'center',
},
content: +obj.percent * 100 + '%', // 显示的文本内容
style: {
Expand Down
4 changes: 3 additions & 1 deletion src/util/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export function getNormalizedValue(val: number | string, scale: Scale) {
switch (val) {
case 'start':
return 0;
case 'center':
Aarebecca marked this conversation as resolved.
Show resolved Hide resolved
return 0.5;
case 'end':
return 1;
case 'median': {
Expand All @@ -37,4 +39,4 @@ export function getNormalizedValue(val: number | string, scale: Scale) {
}

return scale.scale(scaled);
}
}
1 change: 1 addition & 0 deletions tests/unit/util/annotation-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('util annotation', () => {
});

expect(getNormalizedValue('start', scale)).toEqual(0);
expect(getNormalizedValue('center', scale)).toEqual(0.5);
expect(getNormalizedValue('end', scale)).toEqual(1);
expect(near(getNormalizedValue('mean', scale), 0.055999999999999994)).toBe(true);
expect(getNormalizedValue('median', scale)).toEqual(0.065);
Expand Down