Skip to content

Commit

Permalink
fix(sunburst) set the position of label in center when angle is 2π an…
Browse files Browse the repository at this point in the history
…d r0 is 0. close apache#16296
  • Loading branch information
FrankChencc committed Feb 11, 2022
1 parent 98819a6 commit 40246ae
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/chart/sunburst/SunburstPiece.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down Expand Up @@ -219,7 +220,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
if (angle === 2 * Math.PI && layout.r0 === 0) {
r = 0;
}
else {
r = (layout.r + layout.r0) / 2;
}
textAlign = 'center';
}
else if (textAlign === 'left') {
Expand All @@ -239,15 +246,8 @@ class SunburstPiece extends graphic.Sector {
state.style.align = textAlign;
state.style.verticalAlign = getLabelAttr(labelStateModel, 'verticalAlign') || 'middle';

// set the position of label in center when angle is 2π & r0 is 0
if (textAlign === 'center' && angle === 2 * Math.PI && layout.r0 === 0) {
state.x = layout.cx;
state.y = layout.cy;
}
else {
state.x = r * dx + layout.cx;
state.y = r * dy + layout.cy;
}
state.x = r * dx + layout.cx;
state.y = r * dy + layout.cy;

const rotateType = getLabelAttr(labelStateModel, 'rotate');
let rotate = 0;
Expand Down

0 comments on commit 40246ae

Please sign in to comment.