From 38ec1b589e64eac70f4a899674f215141453dd7b Mon Sep 17 00:00:00 2001 From: shier <3207840495@qq.com> Date: Fri, 6 Oct 2023 15:59:30 +0800 Subject: [PATCH] fix #19050 --- src/chart/sunburst/SunburstPiece.ts | 37 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/chart/sunburst/SunburstPiece.ts b/src/chart/sunburst/SunburstPiece.ts index 35d1d1ac00..091d8a1d77 100644 --- a/src/chart/sunburst/SunburstPiece.ts +++ b/src/chart/sunburst/SunburstPiece.ts @@ -20,7 +20,7 @@ import * as zrUtil from 'zrender/src/core/util'; import * as graphic from '../../util/graphic'; import { toggleHoverEmphasis, SPECIAL_STATES, DISPLAY_STATES } from '../../util/states'; -import {createTextStyle} from '../../label/labelStyle'; +import { createTextStyle } from '../../label/labelStyle'; import { TreeNode } from '../../data/Tree'; import SunburstSeriesModel, { SunburstSeriesNodeItemOption, SunburstSeriesOption } from './SunburstSeries'; import GlobalModel from '../../model/Global'; @@ -29,7 +29,7 @@ import { ColorString } from '../../util/types'; import Model from '../../model/Model'; import { getECData } from '../../util/innerStore'; import { getSectorCornerRadius } from '../helper/sectorHelper'; -import {createOrUpdatePatternFromDecal} from '../../util/decal'; +import { createOrUpdatePatternFromDecal } from '../../util/decal'; import ExtensionAPI from '../../core/ExtensionAPI'; import { saveOldStyle } from '../../animation/basicTransition'; import { normalizeRadian } from 'zrender/src/contain/util'; @@ -153,8 +153,8 @@ class SunburstPiece extends graphic.Sector { const focusOrIndices = focus === 'ancestor' ? node.getAncestorsIndices() - : focus === 'descendant' ? node.getDescendantIndices() - : focus; + : focus === 'descendant' ? node.getDescendantIndices() + : focus; toggleHoverEmphasis(this, focusOrIndices, emphasisModel.get('blurScope'), emphasisModel.get('disabled')); } @@ -217,7 +217,12 @@ class SunburstPiece extends graphic.Sector { let textAlign = getLabelAttr(labelStateModel, 'align'); if (labelPosition === 'outside') { r = layout.r + labelPadding; - textAlign = midAngle > Math.PI / 2 ? 'right' : 'left'; + if (layout.clockwise) { + textAlign = midAngle > Math.PI / 2 ? 'right' : 'left'; + } + else { + textAlign = midAngle > -Math.PI * 3 / 2 ? 'right' : 'left'; + } } else { if (!textAlign || textAlign === 'center') { @@ -232,14 +237,28 @@ class SunburstPiece extends graphic.Sector { } else if (textAlign === 'left') { r = layout.r0 + labelPadding; - if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) { - textAlign = 'right'; + if (layout.clockwise) { + if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) { + textAlign = 'right'; + } + } + else { + if (midAngle > -Math.PI * 3 / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) { + textAlign = 'right'; + } } } else if (textAlign === 'right') { r = layout.r - labelPadding; - if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) { - textAlign = 'left'; + if (layout.clockwise) { + if (midAngle > Math.PI / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) { + textAlign = 'left'; + } + } + else { + if (midAngle > -Math.PI * 3 / 2 && !isRadianAroundZero(midAngle - Math.PI / 2)) { + textAlign = 'left'; + } } } }