From b2ee72d5586b3141e7346fe99b2b49ddca2bbb45 Mon Sep 17 00:00:00 2001 From: plainheart Date: Tue, 15 Nov 2022 18:56:24 +0800 Subject: [PATCH] fix(pie): fix `center` may not be converted to the correct point when coordinate system is specified due to being normalized to an array. --- src/chart/pie/pieLayout.ts | 7 +- test/pie-coordinate-system.html | 328 ++++++++++++++++++++------------ 2 files changed, 213 insertions(+), 122 deletions(-) diff --git a/src/chart/pie/pieLayout.ts b/src/chart/pie/pieLayout.ts index 0a6998c70c..c5c52ccfcd 100644 --- a/src/chart/pie/pieLayout.ts +++ b/src/chart/pie/pieLayout.ts @@ -41,15 +41,13 @@ export function getBasicPieLayout(seriesModel: PieSeriesModel, api: ExtensionAPI Pick { const viewRect = getViewRect(seriesModel, api); + // center can be string or number when coordinateSystem is specified let center = seriesModel.get('center'); let radius = seriesModel.get('radius'); if (!zrUtil.isArray(radius)) { radius = [0, radius]; } - if (!zrUtil.isArray(center)) { - center = [center, center]; - } const width = parsePercent(viewRect.width, api.getWidth()); const height = parsePercent(viewRect.height, api.getHeight()); const size = Math.min(width, height); @@ -66,6 +64,9 @@ export function getBasicPieLayout(seriesModel: PieSeriesModel, api: ExtensionAPI cy = point[1] || 0; } else { + if (!zrUtil.isArray(center)) { + center = [center, center]; + } cx = parsePercent(center[0], width) + viewRect.x; cy = parsePercent(center[1], height) + viewRect.y; } diff --git a/test/pie-coordinate-system.html b/test/pie-coordinate-system.html index ad0703eddf..969b7685d1 100644 --- a/test/pie-coordinate-system.html +++ b/test/pie-coordinate-system.html @@ -31,126 +31,15 @@ -
- - - - - - +
+
+
+ + + + + + +