-
Notifications
You must be signed in to change notification settings - Fork 10
feat:update venn layout algorithm #239
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
base: main
Are you sure you want to change the base?
Conversation
已经按照意见改掉了 |
packages/vlayouts/src/venn/venn.ts
Outdated
@@ -23,14 +23,20 @@ export const transform = ( | |||
setField = 'sets', | |||
valueField = 'size', | |||
orientation = Math.PI / 2, | |||
orientationOrder = null | |||
orientationOrder = null, | |||
emptySetKey = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emptySetKey 作用是?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
按照xile的意见改的,可能我的实现对于这个配置项没什么效果
packages/vlayouts/src/venn/venn.ts
Outdated
type: 'circle', | ||
x: x0 + (x1 - x0) / 2, | ||
y: y0 + (y1 - y0) / 2, | ||
radius: Math.max(x1 - x0, y1 - y0) / 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
取了 min 之后,会有内部的 circle 超出的情况,需要处理一下
@@ -1,4 +1,4 @@ | |||
/* Adapted from venn.js by Ben Frederickson | |||
``; /* Adapted from venn.js by Ben Frederickson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是误操作的吧
@@ -60,3 +60,44 @@ test('Path transform of 3 element venn', async () => { | |||
expect(circles[2].x).toBeCloseTo((result[2] as IVennCircleDatum).x, 0); | |||
expect(circles[2].y).toBeCloseTo((result[2] as IVennCircleDatum).y, 0); | |||
}); | |||
|
|||
const data2 = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
从这个单测来看,现在覆盖度还不够,比如说只有一个有效集合的时候,
[
{ sets: [], size: 0, label: 'none' },
{ sets: ['A'], size: 12, label: 'A' },
]
🤔 这个分支是...
🔗 相关 issue 连接
#238
💡 问题的背景&解决方案
📝 Changelog
Venn 图处理增强:
更新了 transform 函数,使其能够处理 sets 字段为空的情况,通过返回具有计算半径和中心的默认圆形来确保空集在 Venn 图中能正确表示
修改了 computeTextCenters 函数,使其能处理包含空集的区域,为这些区域分配默认中心点 (0, 0)
实用函数改进:
增强了 intersectionArea 函数,使其能处理输入 circles 数组为空的情况,通过在 stats 对象中设置默认值并返回面积为 0
测试覆盖:
添加了新的测试用例"具有空集的 3 元素 Venn 图的数据转换",以验证 Venn 图转换中空集的正确处理
元数据更新:
添加了变更文件,记录了 @visactor/vlayouts 和 @visactor/vutils 版本 1.0.5 的发布
☑️ 自测
🚀 Summary
更新transform算法,使得sets为空时返回一个表示含有剩余值的底层大圆。同时,在label.ts和circle-intersection.ts 中增加对边界状况的处理
🔍 Walkthrough
copilot:walkthrough