Skip to content

Commit

Permalink
Merge pull request #19642 from apache/fix/pie-endAngle-emptyCircle
Browse files Browse the repository at this point in the history
fix(pie): fix `endAngle` is not applied on the empty circle
  • Loading branch information
Ovilia authored Feb 26, 2024
2 parents b9f7809 + c539b1f commit 6439551
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/chart/pie/PieView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { setLabelLineStyle, getLabelLineStatesModels } from '../../label/labelGu
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import { getSectorCornerRadius } from '../helper/sectorHelper';
import { saveOldStyle } from '../../animation/basicTransition';
import { getBasicPieLayout } from './pieLayout';
import { getBasicPieLayout, getSeriesLayoutData } from './pieLayout';

/**
* Piece of pie including Sector, Label, LabelLine
Expand Down Expand Up @@ -260,8 +260,9 @@ class PieView extends ChartView {
}
// when all data are filtered, show lightgray empty circle
if (data.count() === 0 && seriesModel.get('showEmptyCircle')) {
const layoutData = getSeriesLayoutData(seriesModel);
const sector = new graphic.Sector({
shape: getBasicPieLayout(seriesModel, api)
shape: extend(getBasicPieLayout(seriesModel, api), layoutData)
});
sector.useStyle(seriesModel.getModel('emptyCircleStyle').getItemStyle());
this._emptyCircleSector = sector;
Expand Down
16 changes: 14 additions & 2 deletions src/chart/pie/pieLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ExtensionAPI from '../../core/ExtensionAPI';
import PieSeriesModel from './PieSeries';
import { SectorShape } from 'zrender/src/graphic/shape/Sector';
import { normalizeArcAngles } from 'zrender/src/core/PathProxy';
import { makeInner } from '../../util/model';

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

[startAngle, endAngle] = angles;

const layoutData = getSeriesLayoutData(seriesModel);
layoutData.startAngle = startAngle;
layoutData.endAngle = endAngle;
layoutData.clockwise = clockwise;

const angleRange = Math.abs(endAngle - startAngle);

// In the case some sector angle is smaller than minAngle
Expand Down Expand Up @@ -224,8 +230,8 @@ export default function pieLayout(
actualEndAngle = actualStartAngle;
}
else {
actualStartAngle = startAngle + dir * idx * angle + halfPadAngle;
actualEndAngle = startAngle + dir * (idx + 1) * angle - halfPadAngle;
actualStartAngle = startAngle + dir * idx * angle + halfPadAngle;
actualEndAngle = startAngle + dir * (idx + 1) * angle - halfPadAngle;
}

layout.startAngle = actualStartAngle;
Expand Down Expand Up @@ -263,3 +269,9 @@ export default function pieLayout(
}
});
}

export const getSeriesLayoutData = makeInner<{
startAngle: number
endAngle: number
clockwise: boolean
}, PieSeriesModel>();
5 changes: 4 additions & 1 deletion test/pie-endAngle.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/runTest/actions/__meta__.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6439551

Please sign in to comment.