Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pie): fix endAngle is not applied on the empty circle #19642

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading