2020import * as zrUtil from 'zrender/src/core/util' ;
2121import * as graphic from '../../util/graphic' ;
2222import { toggleHoverEmphasis , SPECIAL_STATES , DISPLAY_STATES } from '../../util/states' ;
23- import { createTextStyle } from '../../label/labelStyle' ;
23+ import { createTextStyle } from '../../label/labelStyle' ;
2424import { TreeNode } from '../../data/Tree' ;
2525import SunburstSeriesModel , { SunburstSeriesNodeItemOption , SunburstSeriesOption } from './SunburstSeries' ;
2626import GlobalModel from '../../model/Global' ;
@@ -29,7 +29,7 @@ import { ColorString } from '../../util/types';
2929import Model from '../../model/Model' ;
3030import { getECData } from '../../util/innerStore' ;
3131import { getSectorCornerRadius } from '../helper/sectorHelper' ;
32- import { createOrUpdatePatternFromDecal } from '../../util/decal' ;
32+ import { createOrUpdatePatternFromDecal } from '../../util/decal' ;
3333import ExtensionAPI from '../../core/ExtensionAPI' ;
3434import { saveOldStyle } from '../../animation/basicTransition' ;
3535import { normalizeRadian } from 'zrender/src/contain/util' ;
@@ -153,8 +153,8 @@ class SunburstPiece extends graphic.Sector {
153153
154154 const focusOrIndices =
155155 focus === 'ancestor' ? node . getAncestorsIndices ( )
156- : focus === 'descendant' ? node . getDescendantIndices ( )
157- : focus ;
156+ : focus === 'descendant' ? node . getDescendantIndices ( )
157+ : focus ;
158158
159159 toggleHoverEmphasis ( this , focusOrIndices , emphasisModel . get ( 'blurScope' ) , emphasisModel . get ( 'disabled' ) ) ;
160160 }
@@ -217,7 +217,12 @@ class SunburstPiece extends graphic.Sector {
217217 let textAlign = getLabelAttr ( labelStateModel , 'align' ) ;
218218 if ( labelPosition === 'outside' ) {
219219 r = layout . r + labelPadding ;
220- textAlign = midAngle > Math . PI / 2 ? 'right' : 'left' ;
220+ if ( layout . clockwise ) {
221+ textAlign = midAngle > Math . PI / 2 ? 'right' : 'left' ;
222+ }
223+ else {
224+ textAlign = midAngle > - Math . PI * 3 / 2 ? 'right' : 'left' ;
225+ }
221226 }
222227 else {
223228 if ( ! textAlign || textAlign === 'center' ) {
@@ -232,14 +237,28 @@ class SunburstPiece extends graphic.Sector {
232237 }
233238 else if ( textAlign === 'left' ) {
234239 r = layout . r0 + labelPadding ;
235- if ( midAngle > Math . PI / 2 && ! isRadianAroundZero ( midAngle - Math . PI / 2 ) ) {
236- textAlign = 'right' ;
240+ if ( layout . clockwise ) {
241+ if ( midAngle > Math . PI / 2 && ! isRadianAroundZero ( midAngle - Math . PI / 2 ) ) {
242+ textAlign = 'right' ;
243+ }
244+ }
245+ else {
246+ if ( midAngle > - Math . PI * 3 / 2 && ! isRadianAroundZero ( midAngle - Math . PI / 2 ) ) {
247+ textAlign = 'right' ;
248+ }
237249 }
238250 }
239251 else if ( textAlign === 'right' ) {
240252 r = layout . r - labelPadding ;
241- if ( midAngle > Math . PI / 2 && ! isRadianAroundZero ( midAngle - Math . PI / 2 ) ) {
242- textAlign = 'left' ;
253+ if ( layout . clockwise ) {
254+ if ( midAngle > Math . PI / 2 && ! isRadianAroundZero ( midAngle - Math . PI / 2 ) ) {
255+ textAlign = 'left' ;
256+ }
257+ }
258+ else {
259+ if ( midAngle > - Math . PI * 3 / 2 && ! isRadianAroundZero ( midAngle - Math . PI / 2 ) ) {
260+ textAlign = 'left' ;
261+ }
243262 }
244263 }
245264 }
0 commit comments