-
Notifications
You must be signed in to change notification settings - Fork 199
fix: consistently compute the arcSize for edges and vertices #884
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
Conversation
The arcSize of edges missed a division by 2, which was inconsistent with the past mxGraph behavior and the computation done for vertices. This had been introduced by mistake in 0453da2. The result of `getSwimlaneArcSize` was only correct when fallback to the default value. Otherwise, it missed the division by 2 as well. In addition, refactor: - remove duplication in various shapes (introduce Shape.getBaseArcSize) - simplify implementations - add tests - improve JSDOC for CellStyle.arcSize BREAKING CHANGES: The `arcSize` of rounded shapes was not always correctly computed in the past. The computation is now consistent everywhere in the code and matches the mxGraph behavior. To have the same rendering as before for edges, you must multiply the `arcSize` by `2` in your styles.
WalkthroughThis change refactors how the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Shape
participant Style
Client->>Shape: getArcSize(w, h)
alt absoluteArcSize true
Shape->>Shape: getBaseArcSize()
Shape-->>Client: min(baseArcSize, min(w, h) / 2)
else absoluteArcSize false or unset
Shape->>Shape: getBaseArcSize()
Shape-->>Client: min(w, h) * baseArcSize / 100
end
Estimated code review effort3 (~45 minutes) Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (13)
🧠 Learnings (12)📓 Common learningspackages/core/src/view/shape/node/RhombusShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/HexagonShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/RectangleShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/edge/PolylineShape.ts (3)Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/SwimlaneShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/__tests__/view/shape/edge/PolyLineShape.test.ts (1)Learnt from: tbouffard CHANGELOG.md (6)Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/TriangleShape.ts (1)Learnt from: tbouffard packages/core/__tests__/view/shape/node/SwimlaneShape.test.ts (1)Learnt from: tbouffard packages/core/src/types.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/__tests__/view/shape/Shape.test.ts (1)Learnt from: tbouffard 🧬 Code Graph Analysis (1)packages/core/src/view/shape/Shape.ts (1)
🧰 Additional context used🧠 Learnings (12)📓 Common learningspackages/core/src/view/shape/node/RhombusShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/HexagonShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/RectangleShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/edge/PolylineShape.ts (3)Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/SwimlaneShape.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/__tests__/view/shape/edge/PolyLineShape.test.ts (1)Learnt from: tbouffard CHANGELOG.md (6)Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard Learnt from: tbouffard packages/core/src/view/shape/node/TriangleShape.ts (1)Learnt from: tbouffard packages/core/__tests__/view/shape/node/SwimlaneShape.test.ts (1)Learnt from: tbouffard packages/core/src/types.ts (2)Learnt from: tbouffard Learnt from: tbouffard packages/core/__tests__/view/shape/Shape.test.ts (1)Learnt from: tbouffard 🧬 Code Graph Analysis (1)packages/core/src/view/shape/Shape.ts (1)
🔇 Additional comments (24)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|



The arcSize of edges missed a division by 2, which was inconsistent with the past mxGraph behavior and the computation done for vertices.
This had been introduced by mistake in 0453da2.
The result of
getSwimlaneArcSizewas only correct when fallback to the default value. Otherwise, it missed the division by 2 as well.In addition, refactor:
BREAKING CHANGES: The
arcSizeof rounded shapes was not always correctly computed in the past.The computation is now consistent everywhere in the code and matches the mxGraph behavior.
To have the same rendering as before for edges, you must multiply the
arcSizeby2in your styles.Notes
Here are the comparison between the mxGraph code and the incorrectly migrated code in maxGraph.
It includes a diff showing a correct implementation. This PR implements it differently after refactoring and code simplification.
SwimlaneShape.getSwimlaneArcSizeDivision by 2 not correctly positioned (missing parenthesis):
PolylineShape.paintLineMissing division by 2:
maxGraph/packages/core/src/view/shape/edge/PolylineShape.ts
Line 89 in c0d7a50
Summary by CodeRabbit
arcSizeproperty for rounded shapes and its impact on rendering.