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

fix(sunburst) set the position of label in center when angle is 2π. c… #16425

Merged
merged 6 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 7 additions & 1 deletion src/chart/sunburst/SunburstPiece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,13 @@ class SunburstPiece extends graphic.Sector {
}
else {
if (!textAlign || textAlign === 'center') {
r = (layout.r + layout.r0) / 2;
// set the position of label in center when angle is 2π & r0 is 0
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be more clear to be commented

// Put label in the center if it's a circle.

Current comment is just an plain explaination on the code.

if (angle === 2 * Math.PI && layout.r0 === 0) {
r = 0;
}
else {
r = (layout.r + layout.r0) / 2;
}
textAlign = 'center';
}
else if (textAlign === 'left') {
Expand Down
118 changes: 118 additions & 0 deletions test/sunburst-label.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.