diff --git a/__tests__/unit/plots/pie/data-spec.ts b/__tests__/unit/plots/pie/data-spec.ts index bba7586df1..e5d9c25dc6 100644 --- a/__tests__/unit/plots/pie/data-spec.ts +++ b/__tests__/unit/plots/pie/data-spec.ts @@ -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(); }); diff --git a/__tests__/unit/plots/pie/index-spec.ts b/__tests__/unit/plots/pie/index-spec.ts index fd043ea954..95376279d9 100644 --- a/__tests__/unit/plots/pie/index-spec.ts +++ b/__tests__/unit/plots/pie/index-spec.ts @@ -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(); }); diff --git a/src/plots/pie/adaptor.ts b/src/plots/pie/adaptor.ts index 885f8a7c77..b7a8d39bed 100644 --- a/src/plots/pie/adaptor.ts +++ b/src/plots/pie/adaptor.ts @@ -34,6 +34,9 @@ function geometry(params: Params): Params { color, style: pieStyle, }, + args: { + zIndexReversed: true, + }, }, }); @@ -54,6 +57,9 @@ function geometry(params: Params): Params { color, style: pieStyle, }, + args: { + zIndexReversed: true, + }, }, }); @@ -201,6 +207,10 @@ export function pieAnnotation(params: Params): Params { return params; } +/** + * 饼图 tooltip 配置适配,强制 tooltip.shared 为 false + * @param params + */ function adaptorTooltipOptions(params: Params): Params { return get(params, ['options', 'tooltip']) !== false ? deepAssign({}, params, { options: { tooltip: { shared: false } } }) diff --git a/src/plots/pie/contants.ts b/src/plots/pie/contants.ts index 65e4ac10ae..e04cce99ec 100644 --- a/src/plots/pie/contants.ts +++ b/src/plots/pie/contants.ts @@ -1,6 +1,9 @@ import { Plot } from '../../core/plot'; import { deepAssign } from '../../utils'; +/** + * 饼图默认配置项 + */ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), { legend: { position: 'right',