Skip to content

Commit

Permalink
Merge pull request #18962 from linghaoSu/fix/sunburst-label-align
Browse files Browse the repository at this point in the history
fix(sunburst): fix align error caused by float precision
  • Loading branch information
Ovilia authored Aug 30, 2023
2 parents bb1e18c + 8734ed1 commit 5b448f6
Show file tree
Hide file tree
Showing 2 changed files with 1,166 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/chart/sunburst/SunburstPiece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {createOrUpdatePatternFromDecal} from '../../util/decal';
import ExtensionAPI from '../../core/ExtensionAPI';
import { saveOldStyle } from '../../animation/basicTransition';
import { normalizeRadian } from 'zrender/src/contain/util';
import { isRadianAroundZero } from '../../util/number';

const DEFAULT_SECTOR_Z = 2;
const DEFAULT_TEXT_Z = 4;
Expand Down Expand Up @@ -231,13 +232,13 @@ class SunburstPiece extends graphic.Sector {
}
else if (textAlign === 'left') {
r = layout.r0 + labelPadding;
if (midAngle > Math.PI / 2) {
if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'right';
}
}
else if (textAlign === 'right') {
r = layout.r - labelPadding;
if (midAngle > Math.PI / 2) {
if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) {
textAlign = 'left';
}
}
Expand Down
Loading

0 comments on commit 5b448f6

Please sign in to comment.