Skip to content

Commit 6439551

Browse files
authored
Merge pull request #19642 from apache/fix/pie-endAngle-emptyCircle
fix(pie): fix `endAngle` is not applied on the empty circle
2 parents b9f7809 + c539b1f commit 6439551

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

src/chart/pie/PieView.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { setLabelLineStyle, getLabelLineStatesModels } from '../../label/labelGu
3333
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
3434
import { getSectorCornerRadius } from '../helper/sectorHelper';
3535
import { saveOldStyle } from '../../animation/basicTransition';
36-
import { getBasicPieLayout } from './pieLayout';
36+
import { getBasicPieLayout, getSeriesLayoutData } from './pieLayout';
3737

3838
/**
3939
* Piece of pie including Sector, Label, LabelLine
@@ -260,8 +260,9 @@ class PieView extends ChartView {
260260
}
261261
// when all data are filtered, show lightgray empty circle
262262
if (data.count() === 0 && seriesModel.get('showEmptyCircle')) {
263+
const layoutData = getSeriesLayoutData(seriesModel);
263264
const sector = new graphic.Sector({
264-
shape: getBasicPieLayout(seriesModel, api)
265+
shape: extend(getBasicPieLayout(seriesModel, api), layoutData)
265266
});
266267
sector.useStyle(seriesModel.getModel('emptyCircleStyle').getItemStyle());
267268
this._emptyCircleSector = sector;

src/chart/pie/pieLayout.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import ExtensionAPI from '../../core/ExtensionAPI';
2525
import PieSeriesModel from './PieSeries';
2626
import { SectorShape } from 'zrender/src/graphic/shape/Sector';
2727
import { normalizeArcAngles } from 'zrender/src/core/PathProxy';
28+
import { makeInner } from '../../util/model';
2829

2930
const PI2 = Math.PI * 2;
3031
const RADIAN = Math.PI / 180;
@@ -127,6 +128,11 @@ export default function pieLayout(
127128

128129
[startAngle, endAngle] = angles;
129130

131+
const layoutData = getSeriesLayoutData(seriesModel);
132+
layoutData.startAngle = startAngle;
133+
layoutData.endAngle = endAngle;
134+
layoutData.clockwise = clockwise;
135+
130136
const angleRange = Math.abs(endAngle - startAngle);
131137

132138
// In the case some sector angle is smaller than minAngle
@@ -224,8 +230,8 @@ export default function pieLayout(
224230
actualEndAngle = actualStartAngle;
225231
}
226232
else {
227-
actualStartAngle = startAngle + dir * idx * angle + halfPadAngle;
228-
actualEndAngle = startAngle + dir * (idx + 1) * angle - halfPadAngle;
233+
actualStartAngle = startAngle + dir * idx * angle + halfPadAngle;
234+
actualEndAngle = startAngle + dir * (idx + 1) * angle - halfPadAngle;
229235
}
230236

231237
layout.startAngle = actualStartAngle;
@@ -263,3 +269,9 @@ export default function pieLayout(
263269
}
264270
});
265271
}
272+
273+
export const getSeriesLayoutData = makeInner<{
274+
startAngle: number
275+
endAngle: number
276+
clockwise: boolean
277+
}, PieSeriesModel>();

test/pie-endAngle.html

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/runTest/actions/__meta__.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)