Skip to content

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

afkdsghk211331
Copy link

@afkdsghk211331 afkdsghk211331 commented May 14, 2025

🤔 这个分支是...

  • 新功能
  • Bug fix
  • Ts 类型更新
  • 打包优化
  • 性能优化
  • 功能增强
  • 重构
  • 依赖版本更新
  • 代码优化
  • 测试 case 更新
  • 分支合并
  • 网站/文档更新
  • demo 更新
  • Workflow
  • 配置修改
  • 其他 (具体是什么,请补充?)

🔗 相关 issue 连接

#238

💡 问题的背景&解决方案

📝 Changelog

Venn 图处理增强:

更新了 transform 函数,使其能够处理 sets 字段为空的情况,通过返回具有计算半径和中心的默认圆形来确保空集在 Venn 图中能正确表示
修改了 computeTextCenters 函数,使其能处理包含空集的区域,为这些区域分配默认中心点 (0, 0)

实用函数改进:

增强了 intersectionArea 函数,使其能处理输入 circles 数组为空的情况,通过在 stats 对象中设置默认值并返回面积为 0

测试覆盖:

添加了新的测试用例"具有空集的 3 元素 Venn 图的数据转换",以验证 Venn 图转换中空集的正确处理

元数据更新:

添加了变更文件,记录了 @visactor/vlayouts 和 @visactor/vutils 版本 1.0.5 的发布

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ 自测

⚠️ 在提交 PR 之前,请检查一下内容. ⚠️

  • 文档提供了,或者更新,或者不需要
  • Demo 提供了,或者更新,或者不需要
  • Ts 类型定义提供了,或者更新,或者不需要
  • Changelog 提供了,或者不需要

🚀 Summary

更新transform算法,使得sets为空时返回一个表示含有剩余值的底层大圆。同时,在label.ts和circle-intersection.ts 中增加对边界状况的处理

🔍 Walkthrough

copilot:walkthrough

@afkdsghk211331 afkdsghk211331 changed the title docs: update changlog of rush feat:update venn layout algorithm May 14, 2025
@afkdsghk211331 afkdsghk211331 marked this pull request as ready for review May 15, 2025 03:28
@afkdsghk211331
Copy link
Author

已经按照意见改掉了

@afkdsghk211331
Copy link
Author

image
image

目前实现效果如图,或许有更精准的半径计算方法?

@@ -23,14 +23,20 @@ export const transform = (
setField = 'sets',
valueField = 'size',
orientation = Math.PI / 2,
orientationOrder = null
orientationOrder = null,
emptySetKey = ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emptySetKey 作用是?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照xile的意见改的,可能我的实现对于这个配置项没什么效果

type: 'circle',
x: x0 + (x1 - x0) / 2,
y: y0 + (y1 - y0) / 2,
radius: Math.max(x1 - x0, y1 - y0) / 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

radius 应该取 min
image

Copy link
Contributor

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
Copy link
Contributor

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 = [
Copy link
Contributor

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' },
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants