Skip to content

Commit

Permalink
Merge pull request #17920 from apache/fix/pie-coordinate-system
Browse files Browse the repository at this point in the history
fix(pie): fix `center` may not be converted to correct point when coordinate system is specified
  • Loading branch information
plainheart authored Nov 15, 2022
2 parents 7b62040 + b2ee72d commit a28b219
Show file tree
Hide file tree
Showing 2 changed files with 213 additions and 122 deletions.
7 changes: 4 additions & 3 deletions src/chart/pie/pieLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ export function getBasicPieLayout(seriesModel: PieSeriesModel, api: ExtensionAPI
Pick<SectorShape, 'cx' | 'cy' | 'r' | 'r0'> {
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);
Expand All @@ -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;
}
Expand Down
Loading

0 comments on commit a28b219

Please sign in to comment.