-
Notifications
You must be signed in to change notification settings - Fork 12
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
70fb1c2
docs: update changlog of rush
afkdsghk211331 5a931d8
docs: update changlog of rush
afkdsghk211331 9a40233
docs: update changlog of rush
afkdsghk211331 926aef8
chore: delete outdated changelog files
afkdsghk211331 3f68996
Merge branch 'VisActor:main' into feat/venn
afkdsghk211331 ae68b98
fix: filter out empty sets from upstream data in venn transformation
afkdsghk211331 02fd280
feat: enhance venn diagram scaling to handle empty sets
afkdsghk211331 fd39d9c
refactor: simplify empty set handling and centralize diagram offset
afkdsghk211331 97c3e87
refactor: simplify empty set handling and centralize diagram offsets
afkdsghk211331 990870a
test: improve tests for 2 and 1 element venn diagrams with empty sets
afkdsghk211331 ba7a14b
feat: add emptySet option to IVennTransformOptions and update transfo…
afkdsghk211331 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@visactor/vlayouts/feat-venn_2025-05-16-06-12.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "comment": "fix: add emptySetKey option to IVennTransformOptions", | ||
| "type": "none", | ||
| "packageName": "@visactor/vlayouts" | ||
| } | ||
| ], | ||
| "packageName": "@visactor/vlayouts", | ||
| "email": "[email protected]" | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
common/changes/@visactor/vutils/feat-venn_2025-05-16-06-12.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "comment": "fix: add emptySetKey option to IVennTransformOptions", | ||
| "type": "none", | ||
| "packageName": "@visactor/vutils" | ||
| } | ||
| ], | ||
| "packageName": "@visactor/vutils", | ||
| "email": "[email protected]" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import type { IPointLike } from '@visactor/vutils'; | ||
| import { array } from '@visactor/vutils'; | ||
| import { array, isEmpty } from '@visactor/vutils'; | ||
| import type { | ||
| IVennCircleDatum, | ||
| IVennCommonDatum, | ||
|
|
@@ -25,12 +25,18 @@ export const transform = ( | |
| orientation = Math.PI / 2, | ||
| orientationOrder = null | ||
| } = options; | ||
|
|
||
| let circles: Record<VennCircleName, IVennCircle> = {}; | ||
| let textCenters: Record<VennAreaName, IPointLike> = {}; | ||
|
|
||
| if (upstreamData.length > 0) { | ||
| const vennData = upstreamData.map( | ||
| const hasEmptySet = upstreamData.some(area => { | ||
| const sets = array(area[setField]); | ||
| return !sets || sets.length === 0; | ||
| }); | ||
|
|
||
| const nonEmptyData = hasEmptySet ? upstreamData.filter(area => !isEmpty(array(area[setField]))) : upstreamData; | ||
|
|
||
| if (nonEmptyData.length > 0) { | ||
| const vennData = nonEmptyData.map( | ||
| area => | ||
| ({ | ||
| sets: array(area[setField]), | ||
|
|
@@ -39,12 +45,27 @@ export const transform = ( | |
| ); | ||
| let solution = venn(vennData, options); | ||
| solution = normalizeSolution(solution, orientation, orientationOrder); | ||
| circles = scaleSolution(solution, x1 - x0, y1 - y0, x0, y0); | ||
| circles = scaleSolution(solution, x1 - x0, y1 - y0, x0, y0, hasEmptySet); | ||
| textCenters = computeTextCenters(circles, vennData); | ||
| } | ||
|
|
||
| const data = upstreamData.map(area => { | ||
| const sets = array(area[setField]); | ||
| if (!sets || sets.length === 0) { | ||
| return { | ||
| ...area, | ||
| datum: area, | ||
| sets, | ||
| key: 'others', | ||
|
||
| size: area[valueField], | ||
| labelX: undefined, | ||
| labelY: undefined, | ||
| type: 'circle', | ||
| x: x0 + (x1 - x0) / 2, | ||
| y: y0 + (y1 - y0) / 2, | ||
| radius: Math.min(x1 - x0, y1 - y0) / 2 | ||
| } as IVennCircleDatum; | ||
| } | ||
| const key = sets.toString(); | ||
| const textCenter = textCenters[key]; | ||
| const basicDatum = { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
vlayout 的 changelog 内容和 vutils 区分一下