Skip to content

Commit 6be0047

Browse files
authored
Merge pull request #21258 from MC-YCY/fix-label-tangential-fixed
feat(pie):add `tangential-noflip` rotation mode to keep labels tangent…
2 parents 6b82c48 + fa2d67a commit 6be0047

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/chart/pie/PieSeries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface PieStateOption<TCbParams = never> {
6868
labelLine?: PieLabelLineOption
6969
}
7070
interface PieLabelOption extends Omit<SeriesLabelOption, 'rotate' | 'position'> {
71-
rotate?: number | boolean | 'radial' | 'tangential'
71+
rotate?: number | boolean | 'radial' | 'tangential' | 'tangential-noflip'
7272
alignTo?: 'none' | 'labelLine' | 'edge'
7373
edgeDistance?: string | number
7474
/**

src/chart/pie/labelLayout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,15 @@ export default function pieLabelLayout(
484484
const radialAngle = nx < 0 ? -midAngle + PI : -midAngle;
485485
labelRotate = radialAngle;
486486
}
487-
else if (rotate === 'tangential'
487+
else if (rotate === 'tangential' || rotate === 'tangential-noflip'
488488
&& labelPosition !== 'outside' && labelPosition !== 'outer'
489489
) {
490490
let rad = Math.atan2(nx, ny);
491491
if (rad < 0) {
492492
rad = PI * 2 + rad;
493493
}
494494
const isDown = ny > 0;
495-
if (isDown) {
495+
if (isDown && rotate !== 'tangential-noflip') {
496496
rad = PI + rad;
497497
}
498498
labelRotate = rad - PI;

test/pie-label-rotate.html

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)