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

feat(pie): 饼图 geometry 默认对 elemenent 的 zIndex 进行反序 #2266

Merged
merged 1 commit into from
Jan 26, 2021
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
8 changes: 5 additions & 3 deletions __tests__/unit/plots/pie/data-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ describe('饼图 异常数据', () => {

pie.render();

const elements = pie.chart.geometries[0].elements;
const geometry = pie.chart.geometries[0];
const elements = geometry.elements;
expect(elements.length).toBe(5);
expect(every(elements, (ele) => ele.getBBox().width > 0)).toBe(true);
const labels = pie.chart.geometries[0].labelsContainer.getChildren();
const labels = geometry.labelsContainer.getChildren();
expect(every(labels, (label) => (label as IGroup).getChildren()[0].attr('text') === 0)).toBe(true);

// @ts-ignore
expect(geometry.zIndexReversed).toBe(true);
pie.destroy();
});

Expand Down
2 changes: 2 additions & 0 deletions __tests__/unit/plots/pie/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe('pie', () => {
// 绘图数据
expect(elements[0].getModel().style?.fill || elements[0].getModel().color).toBe('blue');
expect(elements[1].getModel().style?.fill || elements[1].getModel().color).toBe('red');
// @ts-ignore
expect(geometry.zIndexReversed).toBe(true);

pie.destroy();
});
Expand Down
10 changes: 10 additions & 0 deletions src/plots/pie/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
color,
style: pieStyle,
},
args: {
zIndexReversed: true,
},
},
});

Expand All @@ -54,6 +57,9 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
color,
style: pieStyle,
},
args: {
zIndexReversed: true,
},
},
});

Expand Down Expand Up @@ -201,6 +207,10 @@ export function pieAnnotation(params: Params<PieOptions>): Params<PieOptions> {
return params;
}

/**
* 饼图 tooltip 配置适配,强制 tooltip.shared 为 false
* @param params
*/
function adaptorTooltipOptions(params: Params<PieOptions>): Params<PieOptions> {
return get(params, ['options', 'tooltip']) !== false
? deepAssign({}, params, { options: { tooltip: { shared: false } } })
Expand Down
3 changes: 3 additions & 0 deletions src/plots/pie/contants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Plot } from '../../core/plot';
import { deepAssign } from '../../utils';

/**
* 饼图默认配置项
*/
export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
legend: {
position: 'right',
Expand Down