Skip to content

Commit

Permalink
fix(sunburst): adjust label rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
susiwen8 committed Feb 17, 2023
1 parent 9335a76 commit 3941fc9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/chart/sunburst/SunburstPiece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { getSectorCornerRadius } from '../helper/pieHelper';
import {createOrUpdatePatternFromDecal} from '../../util/decal';
import ExtensionAPI from '../../core/ExtensionAPI';
import { saveOldStyle } from '../../animation/basicTransition';
import { normalizeRadian } from 'zrender/src/contain/util';

const DEFAULT_SECTOR_Z = 2;
const DEFAULT_TEXT_Z = 4;
Expand Down Expand Up @@ -251,8 +252,8 @@ class SunburstPiece extends graphic.Sector {
const rotateType = getLabelAttr(labelStateModel, 'rotate');
let rotate = 0;
if (rotateType === 'radial') {
rotate = -midAngle;
if (rotate < -Math.PI / 2 || rotate > Math.PI / 2) {
rotate = normalizeRadian(-midAngle);
if (((rotate > Math.PI / 2 && rotate <= Math.PI) || (rotate > Math.PI && rotate <= Math.PI * 1.5))) {
rotate += Math.PI;
}
}
Expand Down
27 changes: 22 additions & 5 deletions test/sunburst-label.html

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

0 comments on commit 3941fc9

Please sign in to comment.